@lintsure/core 0.3.9 → 0.3.10
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.
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +3 -3
- package/dist/src/rules/cra.js +6 -1
- package/dist/src/rules/index.js +15 -5
- package/dist/src/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export * from "./guidance.js";
|
|
|
12
12
|
export { toAssessmentHtml } from "./assessment.js";
|
|
13
13
|
export * from "./knowledge/index.js";
|
|
14
14
|
export { loadPacks, registerPack, type Pack } from "./packs.js";
|
|
15
|
-
export declare const RULES_VERSION = "0.3.
|
|
15
|
+
export declare const RULES_VERSION = "0.3.10";
|
|
16
16
|
/** Shown with every result, in every interface. Lintsure prepares; people decide. */
|
|
17
17
|
export declare const DISCLAIMER: string;
|
|
18
18
|
/** What a report must never be read as. Used in the report and by the MCP server. */
|
package/dist/src/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export { toAssessmentHtml } from "./assessment.js";
|
|
|
19
19
|
export * from "./knowledge/index.js";
|
|
20
20
|
export { loadPacks, registerPack } from "./packs.js";
|
|
21
21
|
import { loadPacks } from "./packs.js";
|
|
22
|
-
export const RULES_VERSION = "0.3.
|
|
22
|
+
export const RULES_VERSION = "0.3.10";
|
|
23
23
|
/** Shown with every result, in every interface. Lintsure prepares; people decide. */
|
|
24
24
|
export const DISCLAIMER = "Lintsure is a readiness tool, not an audit, a certification or legal advice. " +
|
|
25
25
|
"Its rules reflect our reading of the publicly available text of each framework, and they check code only. " +
|
|
@@ -161,12 +161,12 @@ export async function listFiles(root, ignore = []) {
|
|
|
161
161
|
}
|
|
162
162
|
// Code that doesn't ship: tests, fixtures, examples, docs, demos, stories and seed data. Most false alarms in the
|
|
163
163
|
// 139-repo field test came from here. Only the secret rules read these paths, and their findings there are Partial.
|
|
164
|
-
export const NON_SHIPPING = /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fixtures__|e2e|examples?|samples?|demos?|cookbooks?|docs?|stories|storybook|seeds?|seeders|factories|\.dev|benchmarks?|scripts?|\.agents|\.claude|\.cursor)\/|\.(test|spec|stories)\.[cm]?[jt]sx?$|(^|\/)test_[^/]+\.py$|_test\.(py|go)$|(^|\/)(conftest\.py|pytest\.ini|tox\.ini)$|(^|\/)\.env\.(example|sample|template|dist)$|(^|\/)(playwright|vitest|jest|cypress)\.config\.[cm]?[jt]s$/i;
|
|
164
|
+
export const NON_SHIPPING = /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fixtures__|e2e|examples?|samples?|demos?|cookbooks?|docs?|stories|storybook|seeds?|seeders|factories|\.dev|benchmarks?|scripts?|\.agents|\.claude|\.cursor|\.devcontainer)\/|\.(test|spec|stories)\.[cm]?[jt]sx?$|(^|\/)test_[^/]+\.py$|_test\.(py|go)$|(^|\/)(conftest\.py|pytest\.ini|tox\.ini)$|(^|\/)\.env\.(example|sample|template|dist)$|(^|\/)(playwright|vitest|jest|cypress)\.config\.[cm]?[jt]s$/i;
|
|
165
165
|
// In Next.js, Remix and Supabase a folder name is a route or a function name: app/api/demo and a function called
|
|
166
166
|
// "test" are live endpoints (review P3). Inside these roots only real test files count as non-shipping.
|
|
167
167
|
// Example, demo, docs and sample folders inside application source (src/, lib/, server/) are shipping code too.
|
|
168
168
|
const LIVE_ROOT = /(^|\/)(app|pages|api|routes|supabase\/functions|src|lib|server)\//;
|
|
169
|
-
const NS_FOLDER = /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fixtures__|e2e|examples?|samples?|demos?|cookbooks?|docs?|stories|storybook|seeds?|seeders|benchmarks?|scripts?|\.agents|\.claude|\.cursor)\//i;
|
|
169
|
+
const NS_FOLDER = /(^|\/)(tests?|__tests__|__mocks__|mocks?|spec|fixtures?|__fixtures__|e2e|examples?|samples?|demos?|cookbooks?|docs?|stories|storybook|seeds?|seeders|benchmarks?|scripts?|\.agents|\.claude|\.cursor|\.devcontainer)\//i;
|
|
170
170
|
// Dev scripts at the top of a repo (scripts/test-*.mjs, build and seed helpers) and agent tooling (.agents/, .claude/)
|
|
171
171
|
// don't ship: they were the largest single source of false alarms in the 0.3.9 labelled sample (44 of 242).
|
|
172
172
|
const TEST_FILE = /(^|\/)__tests__\/|(^|\/)test[-_]?(utils?|helpers?|rig)\/|(^|\/)test-[^/]+\.[cm]?[jt]s$|[._-]tests?\/|\.(test|spec|stories)\.[cm]?[jt]sx?$|(^|\/)test_[^/]+\.py$|_test\.(py|go)$|(^|\/)(conftest\.py|pytest\.ini|tox\.ini)$/i;
|
package/dist/src/rules/cra.js
CHANGED
|
@@ -39,7 +39,12 @@ export const craRules = [
|
|
|
39
39
|
note: "Piping `curl` or `wget` straight into a shell runs whatever the server sends at that moment, with no check that it is the file you expect. Marked Partial: well-known installers over HTTPS are a common, accepted risk.",
|
|
40
40
|
extensions: [".sh", ".bash", ".yml", ".yaml", ""], fileName: /\.(sh|bash|ya?ml)$|^Dockerfile/i,
|
|
41
41
|
// Quoted text is dropped first: `echo "Install via: curl ... | bash"` tells a person what to run, it runs nothing (field test).
|
|
42
|
-
|
|
42
|
+
// A script served from this machine (a CI test of the project's own installer) or an installer pinned to a version
|
|
43
|
+
// in its URL is not a moving download (0.3.9 review: 8 of 10 sampled findings were these, or prose).
|
|
44
|
+
test: (l) => /\b(curl|wget)\b[^|#\n]*\|\s*(sudo\s+)?(-\S+\s+)*(ba|z|da)?sh\b/.test(l.replace(/"(?:\\.|[^"\\])*"|'[^']*'/g, '""'))
|
|
45
|
+
&& !/\b(localhost|127\.0\.0\.1|0\.0\.0\.0)\b/.test(l) && !/https?:\/\/\S*\/v?\d+\.\d+(\.\d+)?\/\S*install/.test(l),
|
|
46
|
+
// YAML is only run as a script in CI and compose files; elsewhere (manifests, risk registers) it is prose.
|
|
47
|
+
unlessPath: /^(?!.*(\.github\/workflows|\.gitlab-ci|\.circleci|bitbucket-pipelines|azure-pipelines|\.buildkite|docker-compose|(^|\/)compose\.)).*\.ya?ml$/i, ...DRAFT },
|
|
43
48
|
{ id: "ci.write-all-permissions", title: "Workflow gives its token write access to everything", status: "gap", severity: "medium", controls: [UPDATES, A03],
|
|
44
49
|
fix: "Replace `permissions: write-all` with only what the job needs, for example `permissions: contents: read`, and grant write access per job where it's really used.",
|
|
45
50
|
note: "With write-all, any step that is compromised, including a third-party action, can push code, change releases or edit issues with the workflow's token.",
|
package/dist/src/rules/index.js
CHANGED
|
@@ -10,6 +10,8 @@ const LOG_CALL = /\b(console\.(log|info|warn|error|debug)|logger\.\w+|log\.(info
|
|
|
10
10
|
// [^\\] keeps the two alternatives apart: with "." a run of backslashes could match two ways, which backtracks
|
|
11
11
|
// exponentially on text such as an array of regular expressions (found when statements were joined).
|
|
12
12
|
const codeOnly = (l) => l.replace(/(["'`])(?:\\.|(?!\1)[^\\])*\1/g, (s) => (s.match(/\{[^}]*\}/g) ?? []).join(" "));
|
|
13
|
+
// Helpers that hide the raw value before it is logged.
|
|
14
|
+
const MASKED = /\b\w*(mask|hash|pseudonym|redact|anonymi[sz]e|obfuscate|scrub)\w*\s*\(/i;
|
|
13
15
|
const PII = /\b(e-?mail|phone|ssn|social_?security|passport|date_?of_?birth|dob|password|passwd|credit_?card|card_?number|iban)\b/i;
|
|
14
16
|
// The arguments of the first log call on a line, up to its matching ")". Other code on the same line is ignored.
|
|
15
17
|
function logArgs(l) {
|
|
@@ -87,7 +89,9 @@ export const rules = [
|
|
|
87
89
|
note: "Logs are copied to many places and kept for a long time. Personal data in them is hard to find and delete.",
|
|
88
90
|
extensions: CODE,
|
|
89
91
|
// ::add-mask:: tells GitHub Actions to hide the value in its logs.
|
|
90
|
-
|
|
92
|
+
// A value passed through a masking or hashing helper first (maskEmail(), pseudonym(), hash()) is not the raw value:
|
|
93
|
+
// every false alarm on 56 new repos in the 0.3.9 review was masked this way (12 of 12).
|
|
94
|
+
test: (l) => { const a = logArgs(l); return a !== null && !l.includes("::add-mask::") && PII.test(codeOnly(a)) && !MASKED.test(a); },
|
|
91
95
|
...DRAFT,
|
|
92
96
|
},
|
|
93
97
|
{
|
|
@@ -107,10 +111,14 @@ export const rules = [
|
|
|
107
111
|
if (/\bplaceholder\s*[=:]/i.test(l))
|
|
108
112
|
return false; // a form's example text (placeholder="sk_live_...")
|
|
109
113
|
const m = l.match(KEY_FORMATS) ?? l.match(MORE_KEYS);
|
|
110
|
-
|
|
114
|
+
// Placeholders say so: xoxb-your-bot-token, ghp_...fake..., a PEM header followed by "...", or by prose
|
|
115
|
+
// ("starts with -----BEGIN PRIVATE KEY----- and"). 0 of 7 sampled secret findings were real (0.3.9 review).
|
|
116
|
+
return (!!m && !DOC_EXAMPLE.test(m[0]) && !/your[-_]|fake|dummy|placeholder|changeme|sample/.test(m[0]) /* lowercase words: real keys are random */
|
|
117
|
+
&& !/PRIVATE KEY( BLOCK)?-----(["'`]|\.\.\.|\\n\s*\.\.\.|\s+[a-zA-Z])/.test(l)) || serviceRoleJwt(l) || dbUrlWithPassword(l);
|
|
111
118
|
},
|
|
112
|
-
// Translation files mention "API key" and "secret" in every language, never a real key
|
|
113
|
-
|
|
119
|
+
// Translation files mention "API key" and "secret" in every language, never a real key. Type definition files
|
|
120
|
+
// carry documentation examples, and secret-scanner configs list known test keys on purpose (0.3.9 review).
|
|
121
|
+
unlessPath: /(^|\/)(locales?|i18n|translations?|lang)\/|\.d\.ts$|(^|\/)(\.gitleaks\.toml|\.secrets\.baseline|\.trufflehog\.ya?ml)$/i,
|
|
114
122
|
...DRAFT,
|
|
115
123
|
},
|
|
116
124
|
{
|
|
@@ -380,7 +388,7 @@ rules.push(...standardsRules);
|
|
|
380
388
|
// After the push, so the new LLM rules also get their CWE tags.
|
|
381
389
|
for (const r of rules)
|
|
382
390
|
r.controls.push(...(standardsForExisting[r.id] ?? []));
|
|
383
|
-
// Measured on 270
|
|
391
|
+
// Measured on 270 findings reviewed one by one from 139 public repositories (0.3.9). These rules were real in fewer than
|
|
384
392
|
// half of their sampled findings, so they are held back unless --all (show: all) is set, and the report says how many.
|
|
385
393
|
// A rule moves back to high confidence when a fresh labelled sample shows it is real in most findings.
|
|
386
394
|
const MEDIUM_CONFIDENCE = new Set(["xss.raw-html", "error.empty-catch", "sql.string-built", "code.eval", "cmd.shell-built",
|
|
@@ -389,6 +397,8 @@ const MEDIUM_CONFIDENCE = new Set(["xss.raw-html", "error.empty-catch", "sql.str
|
|
|
389
397
|
"jwt.unverified", "jwt.no-expiry", "mass-assignment", "transport.tls-verify-off", "crypto.weak-cipher", "crypto.weak-random-token",
|
|
390
398
|
"ci.script-injection", "log.injection", "log.secret", "auth.hardcoded-password", "mobile.cleartext-traffic", "config.debug-on",
|
|
391
399
|
"mobile.token-in-plain-storage",
|
|
400
|
+
// 0 of 7 real in the 0.3.9 review: the data was the app's own database, cache or worker pipe.
|
|
401
|
+
"deserialize.unsafe",
|
|
392
402
|
// Reworked in 0.3.9 to need credentials; not yet measured on a fresh sample.
|
|
393
403
|
"cors.any-origin"]);
|
|
394
404
|
for (const r of rules)
|
package/dist/src/types.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export interface Rule {
|
|
|
48
48
|
/** Repository check: returns the path of a file the repo should have but doesn't (e.g. "SECURITY.md"),
|
|
49
49
|
* or null. Gets every file path relative to the scanned folder, "/"-separated. Must be pure. */
|
|
50
50
|
repoTest?(files: string[]): string | null;
|
|
51
|
-
/** How often this rule's findings were real in
|
|
51
|
+
/** How often this rule's findings were real in samples reviewed one by one against the code. Medium-confidence findings are only shown
|
|
52
52
|
* with --all (show: all), and the report says how many were held back. Default: high. */
|
|
53
53
|
confidence?: "high" | "medium";
|
|
54
54
|
mappedBy: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lintsure/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Lintsure engine: rules, framework knowledge and reports for readiness checks of AI-written code. Not an audit or legal advice.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|