patchloop 0.2.0__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {patchloop-0.2.0 → patchloop-0.4.0}/PKG-INFO +85 -9
  2. {patchloop-0.2.0 → patchloop-0.4.0}/README.md +83 -8
  3. {patchloop-0.2.0 → patchloop-0.4.0}/pyproject.toml +3 -1
  4. {patchloop-0.2.0 → patchloop-0.4.0}/pyproject.toml.orig +5 -1
  5. patchloop-0.4.0/src/patchloop/cli.py +669 -0
  6. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/detect.py +1 -1
  7. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/github.py +2 -0
  8. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/hints.py +8 -2
  9. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/report/console.py +115 -1
  10. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/report/json_out.py +6 -2
  11. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/report/sarif.py +5 -0
  12. patchloop-0.4.0/src/patchloop/schedule.py +129 -0
  13. patchloop-0.4.0/src/patchloop/targets.py +82 -0
  14. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/workspaces.py +5 -4
  15. patchloop-0.2.0/src/patchloop/cli.py +0 -370
  16. {patchloop-0.2.0 → patchloop-0.4.0}/LICENSE +0 -0
  17. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/__init__.py +0 -0
  18. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/api.py +0 -0
  19. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/build.py +0 -0
  20. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/classify.py +0 -0
  21. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/config.py +0 -0
  22. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/doctor.py +0 -0
  23. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/enrich/__init__.py +0 -0
  24. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/enrich/epss.py +0 -0
  25. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/enrich/kev.py +0 -0
  26. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/fixers/__init__.py +0 -0
  27. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/fixers/base.py +0 -0
  28. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/fixers/js_fix.py +0 -0
  29. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/fixers/poetry_fix.py +0 -0
  30. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/fixers/uv_fix.py +0 -0
  31. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/git_ops.py +0 -0
  32. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/images.py +0 -0
  33. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/isolate.py +0 -0
  34. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/js/__init__.py +0 -0
  35. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/js/lockfiles.py +0 -0
  36. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/js/manifest.py +0 -0
  37. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/js/ranges.py +0 -0
  38. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/js/registry.py +0 -0
  39. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/js/yarn.py +0 -0
  40. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/lockgraph.py +0 -0
  41. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/models.py +0 -0
  42. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/plan.py +0 -0
  43. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/pr_body.py +0 -0
  44. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/prioritize.py +0 -0
  45. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/proc.py +0 -0
  46. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/py.typed +0 -0
  47. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/pypi.py +0 -0
  48. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/report/__init__.py +0 -0
  49. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/runner.py +0 -0
  50. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/scanner.py +0 -0
  51. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/sources/__init__.py +0 -0
  52. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/sources/base.py +0 -0
  53. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/sources/imports.py +0 -0
  54. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/sources/merge.py +0 -0
  55. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/sources/osv.py +0 -0
  56. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/specifiers.py +0 -0
  57. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/validate.py +0 -0
  58. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/versions.py +0 -0
  59. {patchloop-0.2.0 → patchloop-0.4.0}/src/patchloop/worktree.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: patchloop
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: Fix vulnerable dependencies in Python and JavaScript projects: upgrade, test, rescan, one PR.
5
5
  Keywords: security,vulnerabilities,cve,dependencies,uv,poetry,npm,pnpm,yarn
6
6
  Author: Ayush Kumar Singh
@@ -26,12 +26,17 @@ Requires-Dist: rich>=13.7
26
26
  Requires-Dist: tomlkit>=0.13
27
27
  Requires-Dist: typer>=0.12
28
28
  Requires-Python: >=3.12
29
+ Project-URL: Documentation, https://ayushsingh012.github.io/PatchLoop/
29
30
  Project-URL: Repository, https://github.com/AyushSingh012/PatchLoop
30
31
  Project-URL: Issues, https://github.com/AyushSingh012/PatchLoop/issues
31
32
  Description-Content-Type: text/markdown
32
33
 
33
34
  # PatchLoop
34
35
 
36
+ 📖 **[Documentation](https://ayushsingh012.github.io/PatchLoop/)** ·
37
+ **[Which command do I run?](https://ayushsingh012.github.io/PatchLoop/commands/)** ·
38
+ [PyPI](https://pypi.org/project/patchloop/)
39
+
35
40
  Finds vulnerable dependencies in a Python project (uv or Poetry) or a JavaScript project
36
41
  (npm, pnpm or yarn: Next.js, React, Node), upgrades them to the
37
42
  lowest safe version, runs your tests, rescans to confirm each fix, and opens **one** GitHub
@@ -49,6 +54,10 @@ pipx install patchloop # or: uv tool install patchloop
49
54
  patchloop --version
50
55
  ```
51
56
 
57
+ Upgrade with the same tool you installed with: `pipx upgrade patchloop`,
58
+ `uv tool upgrade patchloop`, or `pip install --upgrade patchloop` (there is no
59
+ `pip upgrade`).
60
+
52
61
  To get the latest unreleased code instead:
53
62
  `uv tool install "git+https://github.com/AyushSingh012/PatchLoop"`.
54
63
 
@@ -294,17 +303,24 @@ and refreshed only when it changes.
294
303
  widened in each member that has it; the PR names the file (`packages/web/package.json`).
295
304
  - Tests: the root's `test` script when there is one; otherwise each member's own `test`
296
305
  script, run in that member's folder. uv runs `uv sync --frozen --all-packages` and
297
- `uv run --all-packages pytest -q`. Set `validation.test` to use your own command.
306
+ `uv run --all-packages pytest -q`. Set `validate.test` to use your own command.
298
307
  - npm does not apply new `overrides` to packages under workspace members once they are
299
308
  locked, so a vulnerable package capped by its parent in an npm workspace is reported as
300
309
  blocked instead of forced. pnpm and yarn force it as usual.
301
310
  - Running it on a member folder says which workspace root to use instead.
302
311
 
303
- **Repos with separate projects** (say `backend/` with uv.lock and `web/` with
304
- package-lock.json) are fixed one folder at a time: `patchloop fix backend`, then
305
- `patchloop fix web`. Each folder gets its own branch (`patchloop/security-fixes-backend`)
306
- and its own PR, titled with the folder. Run at the repo root, PatchLoop lists the folders it
307
- found.
312
+ **Several projects at once** (a folder of repos, or a repo with `backend/` and `web/`):
313
+
314
+ ```sh
315
+ patchloop scan # in a folder that isn't a project: scans every one
316
+ patchloop scan backend web # just these folders
317
+ patchloop fix --all --no-push # fix every project, local branches only
318
+ patchloop fix --all --skip legacy # all but some; one branch and PR per project
319
+ ```
320
+
321
+ A summary table lists each project's findings (or fixes and PR link). If one project
322
+ fails, the rest still run; the exit code is 2 if any failed, else 1 if findings remain.
323
+ Details: [Many projects at once](https://ayushsingh012.github.io/PatchLoop/guides/many-projects/).
308
324
 
309
325
  ## Poetry projects
310
326
 
@@ -317,6 +333,66 @@ Poetry 1.x and 2.x both work.
317
333
  Poetry rejects any version that declares `python <4` when the project's range is open-ended
318
334
  (`>=3.12`), so bound it (`>=3.12,<4` or `^3.12`), as most Poetry projects already do.
319
335
 
336
+ ## Run it on a schedule (GitHub Action)
337
+
338
+ GitHub can run PatchLoop on a schedule on its own servers (your computer can be off). Each
339
+ run opens one PR, or updates the open one. The quickest way to set it up:
340
+
341
+ ```sh
342
+ patchloop schedule # every Monday at 06:00 UTC
343
+ patchloop schedule --every day --at 22:00 # or --every week --day fri, --every month
344
+ patchloop schedule apps/web --cron "0 6 * * 1-5" # a project in a subfolder, any cron line
345
+ ```
346
+
347
+ It writes `.github/workflows/patchloop.yml` (or `patchloop-<folder>.yml`) and prints the
348
+ next steps: commit and push the file, and allow Actions to open PRs (below). The file it
349
+ writes looks like this, if you'd rather write it yourself:
350
+
351
+ ```yaml
352
+ name: PatchLoop
353
+ on:
354
+ schedule:
355
+ - cron: "0 6 * * 1" # every Monday 06:00 UTC; pick any schedule
356
+ workflow_dispatch: # adds a "Run workflow" button
357
+
358
+ permissions:
359
+ contents: write
360
+ pull-requests: write
361
+
362
+ jobs:
363
+ fix:
364
+ runs-on: ubuntu-latest
365
+ steps:
366
+ - uses: actions/checkout@v7
367
+ with:
368
+ fetch-depth: 0
369
+ - uses: AyushSingh012/PatchLoop@v0
370
+ ```
371
+
372
+ One-time repo setting: **Settings → Actions → General → Workflow permissions → "Allow
373
+ GitHub Actions to create and approve pull requests"**. Without it GitHub refuses the PR.
374
+
375
+ Inputs (all optional):
376
+
377
+ | Input | Default | What it does |
378
+ |---|---|---|
379
+ | `command` | `fix` | `fix` opens or updates the PR; `scan` only reports |
380
+ | `path` | `.` | the project folder (for a repo with several projects, one job each) |
381
+ | `min-severity` | from patchloop.yml, else `HIGH` | `LOW`, `MEDIUM`, `HIGH` or `CRITICAL` |
382
+ | `args` | | extra arguments, e.g. `--sarif patchloop.sarif` |
383
+ | `version` | newest | PatchLoop version from PyPI |
384
+ | `token` | `GITHUB_TOKEN` | see below |
385
+ | `fail-on-findings` | `false` | fail the job when vulnerabilities remain |
386
+
387
+ The job installs PatchLoop, osv-scanner, and Poetry or pnpm/yarn when the project needs
388
+ them; uv, Node and git are already on GitHub's runners. Your tests run as usual
389
+ (`validation.test` in patchloop.yml sets the command).
390
+
391
+ PRs opened with the default `GITHUB_TOKEN` don't start your other workflows (GitHub's
392
+ rule), so CI won't run on the PR by itself. To get CI on it, pass a personal access token
393
+ or a GitHub App token with `contents` and `pull-requests` write access:
394
+ `token: ${{ secrets.PATCHLOOP_TOKEN }}`.
395
+
320
396
  ## Output files
321
397
 
322
398
  `scan` and `fix` take `--json FILE` and `--sarif FILE`. The SARIF file (2.1.0) points each
@@ -351,8 +427,8 @@ the CLI writes to `--json`. Nothing is printed.
351
427
  when that fails). Public packages served through a private mirror work; packages that
352
428
  exist only in a private registry have no public advisories, so they are not checked.
353
429
  - Poetry has no workspaces, so a Poetry monorepo is fixed one project folder at a time.
354
- - GitHub only. There is no built-in schedule: run it from a scheduled CI job or cron
355
- (re-runs update the one open PR instead of opening another).
430
+ - GitHub only. Scheduling comes from GitHub Actions (above) or cron; re-runs update the
431
+ one open PR instead of opening another.
356
432
 
357
433
  ## Releasing
358
434
 
@@ -1,5 +1,9 @@
1
1
  # PatchLoop
2
2
 
3
+ 📖 **[Documentation](https://ayushsingh012.github.io/PatchLoop/)** ·
4
+ **[Which command do I run?](https://ayushsingh012.github.io/PatchLoop/commands/)** ·
5
+ [PyPI](https://pypi.org/project/patchloop/)
6
+
3
7
  Finds vulnerable dependencies in a Python project (uv or Poetry) or a JavaScript project
4
8
  (npm, pnpm or yarn: Next.js, React, Node), upgrades them to the
5
9
  lowest safe version, runs your tests, rescans to confirm each fix, and opens **one** GitHub
@@ -17,6 +21,10 @@ pipx install patchloop # or: uv tool install patchloop
17
21
  patchloop --version
18
22
  ```
19
23
 
24
+ Upgrade with the same tool you installed with: `pipx upgrade patchloop`,
25
+ `uv tool upgrade patchloop`, or `pip install --upgrade patchloop` (there is no
26
+ `pip upgrade`).
27
+
20
28
  To get the latest unreleased code instead:
21
29
  `uv tool install "git+https://github.com/AyushSingh012/PatchLoop"`.
22
30
 
@@ -262,17 +270,24 @@ and refreshed only when it changes.
262
270
  widened in each member that has it; the PR names the file (`packages/web/package.json`).
263
271
  - Tests: the root's `test` script when there is one; otherwise each member's own `test`
264
272
  script, run in that member's folder. uv runs `uv sync --frozen --all-packages` and
265
- `uv run --all-packages pytest -q`. Set `validation.test` to use your own command.
273
+ `uv run --all-packages pytest -q`. Set `validate.test` to use your own command.
266
274
  - npm does not apply new `overrides` to packages under workspace members once they are
267
275
  locked, so a vulnerable package capped by its parent in an npm workspace is reported as
268
276
  blocked instead of forced. pnpm and yarn force it as usual.
269
277
  - Running it on a member folder says which workspace root to use instead.
270
278
 
271
- **Repos with separate projects** (say `backend/` with uv.lock and `web/` with
272
- package-lock.json) are fixed one folder at a time: `patchloop fix backend`, then
273
- `patchloop fix web`. Each folder gets its own branch (`patchloop/security-fixes-backend`)
274
- and its own PR, titled with the folder. Run at the repo root, PatchLoop lists the folders it
275
- found.
279
+ **Several projects at once** (a folder of repos, or a repo with `backend/` and `web/`):
280
+
281
+ ```sh
282
+ patchloop scan # in a folder that isn't a project: scans every one
283
+ patchloop scan backend web # just these folders
284
+ patchloop fix --all --no-push # fix every project, local branches only
285
+ patchloop fix --all --skip legacy # all but some; one branch and PR per project
286
+ ```
287
+
288
+ A summary table lists each project's findings (or fixes and PR link). If one project
289
+ fails, the rest still run; the exit code is 2 if any failed, else 1 if findings remain.
290
+ Details: [Many projects at once](https://ayushsingh012.github.io/PatchLoop/guides/many-projects/).
276
291
 
277
292
  ## Poetry projects
278
293
 
@@ -285,6 +300,66 @@ Poetry 1.x and 2.x both work.
285
300
  Poetry rejects any version that declares `python <4` when the project's range is open-ended
286
301
  (`>=3.12`), so bound it (`>=3.12,<4` or `^3.12`), as most Poetry projects already do.
287
302
 
303
+ ## Run it on a schedule (GitHub Action)
304
+
305
+ GitHub can run PatchLoop on a schedule on its own servers (your computer can be off). Each
306
+ run opens one PR, or updates the open one. The quickest way to set it up:
307
+
308
+ ```sh
309
+ patchloop schedule # every Monday at 06:00 UTC
310
+ patchloop schedule --every day --at 22:00 # or --every week --day fri, --every month
311
+ patchloop schedule apps/web --cron "0 6 * * 1-5" # a project in a subfolder, any cron line
312
+ ```
313
+
314
+ It writes `.github/workflows/patchloop.yml` (or `patchloop-<folder>.yml`) and prints the
315
+ next steps: commit and push the file, and allow Actions to open PRs (below). The file it
316
+ writes looks like this, if you'd rather write it yourself:
317
+
318
+ ```yaml
319
+ name: PatchLoop
320
+ on:
321
+ schedule:
322
+ - cron: "0 6 * * 1" # every Monday 06:00 UTC; pick any schedule
323
+ workflow_dispatch: # adds a "Run workflow" button
324
+
325
+ permissions:
326
+ contents: write
327
+ pull-requests: write
328
+
329
+ jobs:
330
+ fix:
331
+ runs-on: ubuntu-latest
332
+ steps:
333
+ - uses: actions/checkout@v7
334
+ with:
335
+ fetch-depth: 0
336
+ - uses: AyushSingh012/PatchLoop@v0
337
+ ```
338
+
339
+ One-time repo setting: **Settings → Actions → General → Workflow permissions → "Allow
340
+ GitHub Actions to create and approve pull requests"**. Without it GitHub refuses the PR.
341
+
342
+ Inputs (all optional):
343
+
344
+ | Input | Default | What it does |
345
+ |---|---|---|
346
+ | `command` | `fix` | `fix` opens or updates the PR; `scan` only reports |
347
+ | `path` | `.` | the project folder (for a repo with several projects, one job each) |
348
+ | `min-severity` | from patchloop.yml, else `HIGH` | `LOW`, `MEDIUM`, `HIGH` or `CRITICAL` |
349
+ | `args` | | extra arguments, e.g. `--sarif patchloop.sarif` |
350
+ | `version` | newest | PatchLoop version from PyPI |
351
+ | `token` | `GITHUB_TOKEN` | see below |
352
+ | `fail-on-findings` | `false` | fail the job when vulnerabilities remain |
353
+
354
+ The job installs PatchLoop, osv-scanner, and Poetry or pnpm/yarn when the project needs
355
+ them; uv, Node and git are already on GitHub's runners. Your tests run as usual
356
+ (`validation.test` in patchloop.yml sets the command).
357
+
358
+ PRs opened with the default `GITHUB_TOKEN` don't start your other workflows (GitHub's
359
+ rule), so CI won't run on the PR by itself. To get CI on it, pass a personal access token
360
+ or a GitHub App token with `contents` and `pull-requests` write access:
361
+ `token: ${{ secrets.PATCHLOOP_TOKEN }}`.
362
+
288
363
  ## Output files
289
364
 
290
365
  `scan` and `fix` take `--json FILE` and `--sarif FILE`. The SARIF file (2.1.0) points each
@@ -319,8 +394,8 @@ the CLI writes to `--json`. Nothing is printed.
319
394
  when that fails). Public packages served through a private mirror work; packages that
320
395
  exist only in a private registry have no public advisories, so they are not checked.
321
396
  - Poetry has no workspaces, so a Poetry monorepo is fixed one project folder at a time.
322
- - GitHub only. There is no built-in schedule: run it from a scheduled CI job or cron
323
- (re-runs update the one open PR instead of opening another).
397
+ - GitHub only. Scheduling comes from GitHub Actions (above) or cron; re-runs update the
398
+ one open PR instead of opening another.
324
399
 
325
400
  ## Releasing
326
401
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "patchloop"
3
- version = "0.2.0"
3
+ version = "0.4.0"
4
4
  description = "Fix vulnerable dependencies in Python and JavaScript projects: upgrade, test, rescan, one PR."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -45,6 +45,7 @@ dependencies = [
45
45
  name = "Ayush Kumar Singh"
46
46
 
47
47
  [project.urls]
48
+ Documentation = "https://ayushsingh012.github.io/PatchLoop/"
48
49
  Repository = "https://github.com/AyushSingh012/PatchLoop"
49
50
  Issues = "https://github.com/AyushSingh012/PatchLoop/issues"
50
51
 
@@ -60,6 +61,7 @@ dev = [
60
61
  "types-jsonschema>=4.26.0.20261006",
61
62
  "types-pyyaml>=6.0",
62
63
  ]
64
+ docs = ["mkdocs-material>=9.6"]
63
65
 
64
66
  [build-system]
65
67
  requires = ["uv_build>=0.11.6,<0.12.0"]
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "patchloop"
3
- version = "0.2.0"
3
+ version = "0.4.0"
4
4
  description = "Fix vulnerable dependencies in Python and JavaScript projects: upgrade, test, rescan, one PR."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -34,6 +34,7 @@ dependencies = [
34
34
  ]
35
35
 
36
36
  [project.urls]
37
+ Documentation = "https://ayushsingh012.github.io/PatchLoop/"
37
38
  Repository = "https://github.com/AyushSingh012/PatchLoop"
38
39
  Issues = "https://github.com/AyushSingh012/PatchLoop/issues"
39
40
 
@@ -49,6 +50,9 @@ dev = [
49
50
  "types-jsonschema>=4.26.0.20261006",
50
51
  "types-pyyaml>=6.0",
51
52
  ]
53
+ docs = [
54
+ "mkdocs-material>=9.6",
55
+ ]
52
56
 
53
57
  [build-system]
54
58
  requires = ["uv_build>=0.11.6,<0.12.0"]