Skip to content

Navigation Menu

Sign in
Sign up

test(fuzzing): include full parameter list in fuzzer log output #1760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
webdevsamran wants to merge 2 commits into collective:main
base: main
Choose a base branch
Loading
from webdevsamran:fix/issue-1758
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

1 change: 1 addition & 0 deletions news/1758.internal
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Included the full parameter list in the fuzzer log output for test reproduction. I used AI to assist me with this change. @webdevsamran
10 changes: 6 additions & 4 deletions src/icalendar/fuzzing/ical_fuzzer.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
# limitations under the License.
#
################################################################################
import base64
import contextlib
import sys

import atheris

with atheris.instrument_imports():
import icalendar.cal.calendar
from icalendar.tests.fuzzed import fuzz_v1_calendar
from icalendar.tests.fuzzed import format_fuzz_log, fuzz_v1_calendar


@atheris.instrument_func
Expand All @@ -36,8 +35,11 @@ def TestOneInput(data):
# print the ICS file for the test case extraction
# see https://stackoverflow.com/a/27367173/1320237
Comment on lines 35 to 36

@angatha angatha Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this close to the .encode("UTF-8", "surrogateescape")part.

print(
base64.b64encode(calendar_string.encode("UTF-8", "surrogateescape")).decode(
"ASCII"
format_fuzz_log(
icalendar.cal.calendar.Calendar.from_ical,
multiple,
should_walk,
calendar_string,
Comment on lines 37 to +42

@angatha angatha Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought, this should be called from fuzz_v1_calendar in __init__.py and include the version (see other comment).

)
)

Expand Down
20 changes: 20 additions & 0 deletions src/icalendar/tests/fuzzed/__init__.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@
]


def format_fuzz_log(
from_ical, multiple: bool, should_walk: bool, calendar_string: str
) -> str:
"""Format the log entry for fuzzed test case extraction.

Outputs entrypoint name, parameter values, and base64-encoded calendar content.
"""
import base64

encoded = base64.b64encode(
calendar_string.encode("UTF-8", "surrogateescape")
if isinstance(calendar_string, str)
else calendar_string
).decode("ASCII")
return (
f"{from_ical.__qualname__} multiple={multiple} "
f"should_walk={should_walk} {encoded}"
Comment on lines +57 to +58

@angatha angatha Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"{from_ical.__qualname__} multiple={multiple} "
f"should_walk={should_walk} {encoded}"
f"{version}{from_ical.__qualname__} multiple={multiple} "
f"should_walk={should_walk} {encoded}"

)


def fuzz_v1_calendar(
from_ical, calendar_string: str, multiple: bool, should_walk: bool
):
Expand Down
17 changes: 17 additions & 0 deletions src/icalendar/tests/fuzzed/test_fuzzed_calendars.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,20 @@ def test_fuzz_v1(fuzz_v1_calendar_path):
multiple=True,
should_walk=True,
)


def test_format_fuzz_log():
import base64

from icalendar.tests.fuzzed import format_fuzz_log

content = "BEGIN:VCALENDAR\r\nEND:VCALENDAR"
log = format_fuzz_log(
icalendar.cal.calendar.Calendar.from_ical,
multiple=False,
should_walk=True,
calendar_string=content,
)
assert log.startswith("Calendar.from_ical multiple=False should_walk=True ")
encoded = log.split()[-1]
assert base64.b64decode(encoded).decode("utf-8") == content

AltStyle によって変換されたページ (->オリジナル) /