Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The bundled example has **4 changed files and 5 review prompts**. Also try the s
| Skipped or exclusive test markers | Check which tests actually run |
| Known TLS verification bypass patterns | Restore certificate verification |
| Dynamic `eval` / `exec` calls | Trace input and execution context |
| Dependency manifest without a lockfile in the patch | Check the project’s dependency policy |
| Dependency manifest without a kept or added lockfile in the patch | Check the project’s dependency policy |
| Source changes without changed tests | Confirm existing coverage or add a regression test |
| Binary changes or large file changes | Make space for a separate review |

Expand Down
9 changes: 7 additions & 2 deletions src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,19 @@ export function analyzeDiff(input) {
const manifests = parsed.files.filter(
(file) => isManifest(file.path) && file.additions + file.deletions,
);
if (manifests.length && !parsed.files.some((file) => isLock(file.path)))
if (
manifests.length &&
!parsed.files.some(
(file) => isLock(file.path) && file.status !== "deleted",
)
)
emit(
"lockfile",
"medium",
manifests[0],
null,
"Check dependency reproducibility",
"A dependency manifest changed, but no recognized lockfile is present in this patch. Some ecosystems do not require one.",
"A dependency manifest changed, but this patch contains no recognized lockfile that is kept or added. Some ecosystems do not require one.",
"Confirm the project’s dependency policy and regenerate the lockfile if applicable.",
);
const runtime = parsed.files.filter(
Expand Down
25 changes: 25 additions & 0 deletions tests/engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,31 @@ test("lockfile in patch suppresses dependency reproducibility prompt", () => {
);
assert.ok(!report.findings.some((f) => f.rule === "lockfile"));
});
test("deleted lockfiles do not suppress dependency reproducibility prompts", () => {
const manifest = patch(
"package.json",
'@@ -1 +1 @@\n-{"x":"1"}\n+{"x":"2"}',
);
for (const lockfile of [
"diff --git a/package-lock.json b/package-lock.json\ndeleted file mode 100644\n--- a/package-lock.json\n+++ /dev/null\n@@ -1 +0,0 @@\n-old-lock",
"--- a/package-lock.json\n+++ /dev/null\n@@ -1 +0,0 @@\n-old-lock",
"diff --git a/package-lock.json b/old-lock.txt\nsimilarity index 100%\nrename from package-lock.json\nrename to old-lock.txt",
]) {
const report = analyzeDiff(`${manifest}\n${lockfile}`);
const finding = report.findings.find((f) => f.rule === "lockfile");
assert.ok(finding);
assert.equal(finding.path, "package.json");
assert.equal(finding.severity, "medium");
}
});
test("a replacement lockfile still suppresses the dependency prompt", () => {
const report = analyzeDiff(
patch("package.json", '@@ -1 +1 @@\n-{"x":"1"}\n+{"x":"2"}') +
"\ndiff --git a/package-lock.json b/package-lock.json\ndeleted file mode 100644\n--- a/package-lock.json\n+++ /dev/null\n@@ -1 +0,0 @@\n-old-lock\n" +
"diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml\nnew file mode 100644\n--- /dev/null\n+++ b/pnpm-lock.yaml\n@@ -0,0 +1 @@\n+lockfileVersion: '9.0'",
);
assert.ok(!report.findings.some((f) => f.rule === "lockfile"));
});
test("unsupported or empty input fails clearly and size limits are enforced", () => {
for (const input of ["", "hello", "x".repeat(limits.bytes + 1)])
assert.throws(() => analyzeDiff(input));
Expand Down
Loading