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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v1.0.4

- Keep the report's tool version synchronized with `package.json` rather than a stale hard-coded value.
- Add a regression assertion that verifies the generated report version matches package metadata.

## v1.0.3

- Fix Markdown spacing so the license headings render correctly after the wallet details blocks in both README languages.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diffshield-action",
"version": "1.0.3",
"version": "1.0.4",
"private": true,
"description": "Read-only GitHub pull request risk review action",
"type": "module",
Expand Down
5 changes: 3 additions & 2 deletions src/scan.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { execFileSync } from 'node:child_process';
import { appendFileSync, writeFileSync } from 'node:fs';
import { appendFileSync, readFileSync, writeFileSync } from 'node:fs';

const SEVERITY = { critical: 4, high: 3, medium: 2, low: 1, info: 0 };
const BASE = process.env.DIFFSHIELD_BASE_SHA ?? '';
const HEAD = process.env.DIFFSHIELD_HEAD_SHA ?? '';
const failOn = (process.env.DIFFSHIELD_FAIL_ON ?? 'high').toLowerCase();
const maxFindings = Number.parseInt(process.env.DIFFSHIELD_MAX_FINDINGS ?? '100', 10);
const packageVersion = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
const findings = [];

function add(severity, category, path, line, message, recommendation) {
Expand Down Expand Up @@ -151,7 +152,7 @@ function main() {

const score = riskScore(findings);
const counts = Object.fromEntries(Object.keys(SEVERITY).map(level => [level, findings.filter(item => item.severity === level).length]));
const report = { tool: 'DiffShield', version: '1.0.0', base: BASE, head: HEAD, riskScore: score, counts, findings };
const report = { tool: 'DiffShield', version: packageVersion, base: BASE, head: HEAD, riskScore: score, counts, findings };
const summary = [];
summary.push('## 🛡️ DiffShield analysis');
summary.push('');
Expand Down
1 change: 1 addition & 0 deletions test/scan.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function fixture(files, options = {}) {
test('clean changes produce a zero-risk report', t => {
const f = fixture({ 'src/app.js': 'export const value = 42;\n' }); t.after(() => rmSync(f.dir, { recursive: true, force: true }));
assert.equal(f.result.status, 0); assert.equal(f.report.riskScore, 0); assert.equal(f.report.findings.length, 0);
assert.equal(f.report.version, JSON.parse(readFileSync(path.join(repository, 'package.json'), 'utf8')).version);
});

test('English and Russian README examples pin the same immutable Action release', () => {
Expand Down
Loading