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
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ jobs:
- run: npm run build
- run: cd cli && npm publish --access public --provenance
- run: cd packages/complex-md-mcp && npm publish --access public --provenance
# The same CLI build under the name complex.md, so `npx complex.md` works.
# Trusted publishing needs a package that exists: the maintainer makes the
# first publish by hand and adds this workflow as its trusted publisher.
# Until then the step skips and the release stays green.
- name: publish complex.md
run: |
if npm view complex.md version >/dev/null 2>&1; then
cd cli && npm pkg set name=complex.md && npm publish --access public --provenance
else
echo "complex.md is not on npm yet; skipped"
fi
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ format.

## Unreleased

**Intent:** the command was `complex-md`, 10 characters, and the project is named complex.md. A short command is easier to type and to remember.

**Change:** the package installs 3 commands that run the same entry: `complex`, `complex.md` and `complex-md`. `complex-md` stays, so the hooks, CI files and AGENTS.md lines that earlier versions wrote keep working. The `complex.md` command lets `npx complex.md` pick the entry once the package is also published under that name. `cli/test/bin-names.test.js` checks the 3 names.

**Intent:** a key that a commit added stays in every clone of the history after a later commit deletes it, and the map had no way to show it. The bundle redaction also had its own 11 rules in code, so a second detector would drift from it.

**Change:** new opt in command `complex-md exposure` (E1). It scans the tracked files and every line that a commit reachable from HEAD added (`--all-refs` for every ref, `--no-history` for the files only), with `git log -p` streamed and lockfiles, `node_modules`, `vendor` and minified files excluded in the git command. A partial clone skips the history and says so, since git would fetch each old blob. The 54 rules are data in `cli/rules/exposure.json` (53 known shapes, CWE ids, a severity, a confidence and a directive each, and 1 heuristic, `generic-assignment`, at low confidence); every quantifier is bounded and a rule names predicates, never code. The bundle redaction now uses the same rules. Output: `.complex-md/exposure-report.json` and with `--sarif` a SARIF 2.1.0 file with `partialFingerprints`; no output holds a value, only rule, path, line, commits, length, entropy and a fingerprint. `.complex-md/exposure.json` holds disabled rules, allows with a reason and an expiry compared with the commit date of HEAD, a baseline (`--baseline` writes it) and own rules; `--config-ref` reads it from a commit for CI; a comment `complex-md: allow <rule-id> <reason>` allows 1 rule on its line. A finding in a test path is labelled and 1 severity step lower. `--strict` exits 1 on a new finding and 2 on a broken config. A `.gitignore` entry written before this release gets `!.complex-md/exposure.json` once. Measured on a development set of 9 snapshots of 4 public repositories with hard-coded credential advisories: 61 distinct findings (2 exact, 59 heuristic), 46 credentials, 14 unclear, 1 not, labelled by the author; every value that left a file was reported with the commit that removed it. The full history of django (35,052 commits) took 99 s, of which `git log -p` took 41 s. `cli/test/exposure.test.js`, `cli/test/exposure-rules.test.js`, `cli/test/partial-clone.test.js` and `cli/test/gitignore.test.js` cover it with fake keys built from fragments.
Expand Down
2 changes: 2 additions & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
},
"type": "module",
"bin": {
"complex": "bin/complex-md.js",
"complex.md": "bin/complex-md.js",
"complex-md": "bin/complex-md.js"
},
"files": [
Expand Down
25 changes: 25 additions & 0 deletions cli/test/bin-names.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';

const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));

test('complex, complex.md and complex-md all run the one CLI entry', () => {
assert.deepEqual(Object.keys(pkg.bin).sort(), ['complex', 'complex-md', 'complex.md']);
for (const name of Object.keys(pkg.bin)) assert.equal(pkg.bin[name], 'bin/complex-md.js', name);
});

test('npx finds a bin named like the package under both published names', () => {
// npx runs the bin whose name equals the package name when a package has more than one bin.
assert.ok(pkg.bin[pkg.name], `no bin named ${pkg.name}`);
assert.ok(pkg.bin['complex.md'], 'no bin named complex.md for the complex.md package');
});

test('the entry prints its version', () => {
const entry = fileURLToPath(new URL('../bin/complex-md.js', import.meta.url));
const r = spawnSync(process.execPath, [entry, '--version'], { encoding: 'utf8' });
assert.equal(r.status, 0, r.stderr);
assert.match(r.stdout + r.stderr, new RegExp(pkg.version.replace(/\./g, '\\.')));
});
Loading