Skip to content

Commit cdee552

Browse files
authored
Merge branch 'master' into fuzzers-upstream
2 parents e78ec69 + d1852a5 commit cdee552

File tree

8 files changed

+68
-20
lines changed

8 files changed

+68
-20
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313

1414
- name: Set up Python 3.8
1515
uses: actions/setup-python@v4

.github/workflows/fuzz.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
name: fuzzing
2+
3+
# This action runs fuzzing for a brief period of time,
4+
# only aginst the actual code added in the PR.
5+
# It is intended a relatively quick check,
6+
# to guard against code introducing crashes in the Markdown parsing,
7+
# which should in principle always run against any text input.
8+
# See: https://google.github.io/oss-fuzz/getting-started/continuous-integration/#how-it-works
9+
# Note, to reproduce a crash locally, copy to `testcase` file` and run: `tox -e fuzz`
10+
211
on:
3-
push:
4-
branches: [master]
512
pull_request:
13+
paths-ignore: ['docs/**', 'tests/**']
614

715
jobs:
816
Fuzzing:
@@ -19,7 +27,7 @@ jobs:
1927
with:
2028
oss-fuzz-project-name: 'markdown-it-py'
2129
language: python
22-
fuzz-seconds: 600
30+
fuzz-seconds: 60
2331
- name: Upload Crash
2432
uses: actions/upload-artifact@v3
2533
if: failure() && steps.build.outcome == 'success'

.github/workflows/tests.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Set up Python 3.8
2424
uses: actions/setup-python@v4
2525
with:
@@ -34,7 +34,7 @@ jobs:
3434
python-version: ['pypy-3.7', '3.7', '3.8', '3.9', '3.10', '3.11']
3535

3636
steps:
37-
- uses: actions/checkout@v2
37+
- uses: actions/checkout@v3
3838
- name: Set up Python ${{ matrix.python-version }}
3939
uses: actions/setup-python@v4
4040
with:
@@ -54,6 +54,7 @@ jobs:
5454
flags: pytests
5555
file: ./coverage.xml
5656
fail_ci_if_error: true
57+
token: ${{ secrets.CODECOV_TOKEN }}
5758

5859
test-plugins:
5960

@@ -62,7 +63,7 @@ jobs:
6263
matrix:
6364
python-version: ['3.8']
6465
steps:
65-
- uses: actions/checkout@v2
66+
- uses: actions/checkout@v3
6667
- name: Set up Python ${{ matrix.python-version }}
6768
uses: actions/setup-python@v4
6869
with:
@@ -82,7 +83,7 @@ jobs:
8283

8384
runs-on: ubuntu-latest
8485
steps:
85-
- uses: actions/checkout@v2
86+
- uses: actions/checkout@v3
8687

8788
- name: Set up Python 3.8
8889
uses: actions/setup-python@v4
@@ -112,7 +113,7 @@ jobs:
112113
runs-on: ubuntu-latest
113114
steps:
114115
- name: Checkout source
115-
uses: actions/checkout@v2
116+
uses: actions/checkout@v3
116117
- name: Set up Python 3.8
117118
uses: actions/setup-python@v4
118119
with:

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
- id: isort
3030

3131
- repo: https://github.com/psf/black
32-
rev: 23.1.0
32+
rev: 23.3.0
3333
hooks:
3434
- id: black
3535

@@ -40,7 +40,7 @@ repos:
4040
additional_dependencies: [flake8-bugbear~=22.7]
4141

4242
- repo: https://github.com/pre-commit/mirrors-mypy
43-
rev: v1.0.1
43+
rev: v1.2.0
4444
hooks:
4545
- id: mypy
4646
additional_dependencies: [mdurl]

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def run_apidoc(app):
102102
this_folder = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
103103
api_folder = os.path.join(this_folder, "api")
104104
module_path = os.path.normpath(os.path.join(this_folder, "../"))
105-
ignore_paths = ["../profiler.py", "../conftest.py", "../tests", "../benchmarking"]
105+
ignore_paths = ["../scripts", "../conftest.py", "../tests", "../benchmarking"]
106106
ignore_paths = [
107107
os.path.normpath(os.path.join(this_folder, p)) for p in ignore_paths
108108
]

scripts/build_fuzzers.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Build fuzzers idempotently in a given folder."""
2+
import argparse
3+
from pathlib import Path
4+
import subprocess
5+
6+
7+
def main():
8+
"""Build fuzzers idempotently in a given folder."""
9+
parser = argparse.ArgumentParser()
10+
parser.add_argument("folder")
11+
args = parser.parse_args()
12+
folder = Path(args.folder)
13+
if not folder.exists():
14+
print(f"Cloning google/oss-fuzz into: {folder}")
15+
folder.mkdir(parents=True)
16+
subprocess.check_call(
17+
[
18+
"git",
19+
"clone",
20+
"--single-branch",
21+
"https://github.com/google/oss-fuzz",
22+
str(folder),
23+
]
24+
)
25+
else:
26+
print(f"Using google/oss-fuzz in: {folder}")
27+
if not (folder / "build").exists():
28+
print(f"Building fuzzers in: {folder / 'build'}")
29+
subprocess.check_call(
30+
[
31+
"python",
32+
str(folder / "infra" / "helper.py"),
33+
"build_fuzzers",
34+
"markdown-it-py",
35+
]
36+
)
37+
else:
38+
print(f"Using existing fuzzers in: {folder / 'build'}")
39+
40+
41+
if __name__ == "__main__":
42+
main()
File renamed without changes.

tox.ini

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,17 @@ allowlist_externals =
5555
dot
5656
commands =
5757
mkdir -p "{toxworkdir}/prof"
58-
python -m cProfile -o "{toxworkdir}/prof/output.pstats" profiler.py
58+
python -m cProfile -o "{toxworkdir}/prof/output.pstats" scripts/profiler.py
5959
gprof2dot -f pstats -o "{toxworkdir}/prof/output.dot" "{toxworkdir}/prof/output.pstats"
6060
dot -Tsvg -o "{toxworkdir}/prof/output.svg" "{toxworkdir}/prof/output.dot"
6161
python -c 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "output.svg"))'
6262

6363
[testenv:fuzz]
64-
description = run fuzzer
64+
description = run fuzzer on testcase file
65+
; See: https://google.github.io/oss-fuzz/
6566
deps = atheris
66-
allowlist_externals =
67-
git
68-
commands_pre =
69-
git clone --single-branch https://github.com/google/oss-fuzz {envtmpdir}/oss-fuzz
70-
python {envtmpdir}/oss-fuzz/infra/helper.py build_fuzzers markdown-it-py
71-
commands = python {envtmpdir}/oss-fuzz/infra/helper.py run_fuzzer markdown-it-py fuzz_markdown
67+
commands_pre = python scripts/build_fuzzers.py {envdir}/oss-fuzz
68+
commands = python {envdir}/oss-fuzz/infra/helper.py reproduce markdown-it-py fuzz_markdown {posargs:testcase}
7269

7370
[flake8]
7471
max-line-length = 100

0 commit comments

Comments
 (0)