@birdapi/velinstyle 1.2.1 → 1.3.0
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/README.de.md +148 -11
- package/README.md +174 -16
- package/cli/__fixtures__/atelier-library/showcases/01-login/app.css +1 -0
- package/cli/__fixtures__/atelier-library/showcases/01-login/app.js +2 -0
- package/cli/__fixtures__/atelier-library/showcases/01-login/index.html +5 -0
- package/cli/__fixtures__/atelier-library/showcases/04-pricing/app.css +1 -0
- package/cli/__fixtures__/atelier-library/showcases/04-pricing/app.js +2 -0
- package/cli/__fixtures__/atelier-library/showcases/04-pricing/index.html +5 -0
- package/cli/__fixtures__/atelier-library/showcases/36-calendar/app.css +1 -0
- package/cli/__fixtures__/atelier-library/showcases/36-calendar/app.js +2 -0
- package/cli/__fixtures__/atelier-library/showcases/36-calendar/index.html +5 -0
- package/cli/atelier-catalog.json +1267 -0
- package/cli/atelier-formats.js +159 -0
- package/cli/atelier.js +382 -0
- package/cli/blueprints/empty-state.html +3 -5
- package/cli/cli-manifest.json +441 -161
- package/cli/docgen/extract-cli.js +2 -1
- package/cli/docs-generate.js +9 -0
- package/cli/experience.js +173 -0
- package/cli/index.js +1384 -361
- package/cli/motion.js +738 -0
- package/cli/production/component-graph.json +166 -0
- package/cli/production/explain.js +52 -0
- package/cli/production/extract.js +278 -0
- package/cli/production/graph.js +102 -0
- package/cli/production/report.js +168 -0
- package/cli/production/run.js +355 -0
- package/cli/production/trim-css.js +177 -0
- package/cli/production/trim-fonts.js +23 -0
- package/cli/production/trim-icons.js +38 -0
- package/cli/production/trim-js.js +48 -0
- package/cli/production/trim-motion.js +22 -0
- package/cli/production/trim-themes.js +50 -0
- package/cli/production/watch.js +38 -0
- package/cli/review.js +48 -1
- package/cli/scripts/write-atelier-fixtures.mjs +33 -0
- package/cli/security.js +190 -0
- package/cli/skills.js +53 -10
- package/cli/transparency.js +140 -41
- package/cli/workflow.js +32 -17
- package/components/index.js +3 -0
- package/components/runtime/component-loaders.js +3 -0
- package/components/velin-drawer.js +43 -4
- package/components/velin-empty-state.js +83 -0
- package/components/velin-modal.js +76 -15
- package/components/velin-otp-input.js +220 -0
- package/components/velin-password-strength.js +147 -0
- package/components/velin-sheet.js +49 -4
- package/components/velin-theme-toggle.js +15 -1
- package/core/a11y/component-contracts.json +391 -255
- package/core/attributes/registry.js +1 -1
- package/core/meta/knowledge/components.json +75 -3
- package/core/motion/analyze.js +38 -0
- package/core/motion/blueprint.js +51 -0
- package/core/motion/composer.js +114 -0
- package/core/motion/data/registry.json +352 -0
- package/core/motion/effects.js +17 -1
- package/core/motion/index.js +112 -9
- package/core/motion/optimize.js +44 -0
- package/core/motion/policy.js +77 -0
- package/core/motion/registry.js +131 -0
- package/core/motion/review.js +59 -0
- package/core/motion/scan.js +150 -0
- package/core/motion/timeline.js +68 -0
- package/core/motion/transitions.js +49 -0
- package/core/motion/triggers.js +168 -0
- package/core/security/checks/fs.js +92 -0
- package/core/security/detect.js +35 -0
- package/core/security/engine.js +116 -0
- package/core/security/index.js +18 -0
- package/core/security/registry.js +85 -0
- package/core/security/report/report.js +113 -0
- package/core/security/rules/ci/index.js +146 -0
- package/core/security/rules/consumer/index.js +174 -0
- package/core/security/rules/deps/index.js +182 -0
- package/core/security/rules/index.js +24 -0
- package/core/security/rules/publish/index.js +230 -0
- package/core/security/rules/repo/index.js +143 -0
- package/core/security/rules/secrets/index.js +133 -0
- package/core/security/score/dependency-health.js +53 -0
- package/core/security/score/release-health.js +66 -0
- package/core/security/score/score.js +102 -0
- package/core/security/timeline/timeline.js +76 -0
- package/dist/chunks/attributes-2ORR27KA.js +404 -0
- package/dist/chunks/attributes-HK7VIOLA.js +1080 -0
- package/dist/chunks/attributes-VRHHVNDO.js +1080 -0
- package/dist/chunks/chunk-MYKUI364.js +116 -0
- package/dist/chunks/chunk-NEVBPD5T.js +116 -0
- package/dist/chunks/chunk-Y6HN7HWX.js +116 -0
- package/dist/chunks/runtime-entry.js +1 -1
- package/dist/chunks/velin-drawer-A7Q7EBOS.js +162 -0
- package/dist/chunks/velin-empty-state-3NTUH2RF.js +81 -0
- package/dist/chunks/velin-modal-3MV4FYBK.js +231 -0
- package/dist/chunks/velin-otp-input-PSK42MM6.js +207 -0
- package/dist/chunks/velin-password-strength-TAXMLSED.js +136 -0
- package/dist/chunks/velin-sheet-N2VVYXFP.js +157 -0
- package/dist/chunks/velin-theme-toggle-J2NHC7IM.js +304 -0
- package/dist/llms.txt +4 -4
- package/dist/search-index.json +232 -5
- package/dist/velin-agent.json +433 -46
- package/dist/velinstyle-components.iife.js +3695 -2272
- package/dist/velinstyle-components.js +3698 -2271
- package/dist/velinstyle-components.min.js +262 -120
- package/dist/velinstyle.css +96 -13
- package/dist/velinstyle.d.ts +3 -0
- package/dist/velinstyle.min.css +1 -1
- package/package.json +19 -4
- package/packages/velinstyle-cli-core/package.json +11 -0
- package/packages/velinstyle-cli-core/src/config.js +84 -0
- package/packages/velinstyle-cli-core/src/contract.js +56 -0
- package/packages/velinstyle-cli-core/src/event-bus.js +50 -0
- package/packages/velinstyle-cli-core/src/index.js +18 -0
- package/packages/velinstyle-cli-core/src/lifecycle.js +33 -0
- package/packages/velinstyle-cli-core/src/runner.js +129 -0
- package/packages/velinstyle-cli-registry/data/commands.json +1216 -0
- package/packages/velinstyle-cli-registry/data/layouts.json +33 -0
- package/packages/velinstyle-cli-registry/data/widgets.json +35 -0
- package/packages/velinstyle-cli-registry/package.json +13 -0
- package/packages/velinstyle-cli-registry/src/index.js +88 -0
- package/packages/velinstyle-cli-renderer/package.json +8 -0
- package/packages/velinstyle-cli-renderer/src/index.js +286 -0
- package/packages/velinstyle-cli-theme/package.json +8 -0
- package/packages/velinstyle-cli-theme/src/index.js +84 -0
- package/packages/velinstyle-cli-ui/package.json +8 -0
- package/packages/velinstyle-cli-ui/src/index.js +34 -0
- package/packages/velinstyle-motion/README.md +81 -0
- package/packages/velinstyle-motion/package.json +37 -0
- package/packages/velinstyle-motion/src/ai/mini-prompt.js +119 -0
- package/packages/velinstyle-motion/src/ai/provider.js +59 -0
- package/packages/velinstyle-motion/src/ai/providers/pixverse-setup.js +402 -0
- package/packages/velinstyle-motion/src/ai/providers/pixverse.js +245 -0
- package/packages/velinstyle-motion/src/config.js +257 -0
- package/packages/velinstyle-motion/src/export/html-clip.js +141 -0
- package/packages/velinstyle-motion/src/index.js +304 -0
- package/packages/velinstyle-motion/src/jobs/cache.js +30 -0
- package/packages/velinstyle-motion/src/jobs/queue.js +69 -0
- package/packages/velinstyle-motion/src/jobs/usage.js +53 -0
- package/packages/velinstyle-motion/src/local/effects.js +139 -0
- package/packages/velinstyle-motion/src/local/engine.js +96 -0
- package/packages/velinstyle-motion/src/providers-catalog.js +44 -0
- package/packages/velinstyle-motion/src/registry/presets.js +25 -0
- package/packages/velinstyle-motion/src/registry/presets.json +85 -0
- package/packages/velinstyle-motion/src/ux/cost-gate.js +37 -0
- package/packages/velinstyle-motion/src/ux/pixverse-gate.js +153 -0
- package/packages/velinstyle-motion/src/ux/wizard.js +171 -0
- package/packages/velinstyle-motion/src/validate-image.js +91 -0
- package/packages/velinstyle-skills/catalog.json +1 -1
- package/packages/velinstyle-skills/registry.json +1 -142
- package/packages/velinstyle-skills/skills/velin-motion-reduced-safe/SKILL.md +1 -1
- package/packages/velinstyle-skills/skills/velin-motion-reveal-feedback/SKILL.md +1 -1
- package/src/components/data-table.css +19 -0
- package/src/components/empty-auth.css +33 -0
- package/src/components/table.css +16 -6
- package/src/tokens/motion.css +7 -0
- package/src/utilities/scroll-animation.css +66 -0
- package/src/velinstyle.css +1 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { registerSecurityRule } from '../../registry.js';
|
|
2
|
+
import { fileExists, readJson, readText, walkFiles, rel } from '../../checks/fs.js';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
export function registerConsumerRules() {
|
|
6
|
+
registerSecurityRule({
|
|
7
|
+
id: 'consumer.velinstyle-installed',
|
|
8
|
+
category: 'consumer',
|
|
9
|
+
severity: 'warning',
|
|
10
|
+
modes: ['consumer', 'audit', 'scan'],
|
|
11
|
+
title: 'VelinStyle installed',
|
|
12
|
+
run(ctx) {
|
|
13
|
+
const pkg = readJson(join(ctx.root, 'package.json')) || {};
|
|
14
|
+
if (pkg.name === '@birdapi/velinstyle') return [];
|
|
15
|
+
const dep = pkg.dependencies?.['@birdapi/velinstyle'] || pkg.devDependencies?.['@birdapi/velinstyle'];
|
|
16
|
+
const vendor =
|
|
17
|
+
fileExists(join(ctx.root, 'vendor', 'velinstyle.min.css'))
|
|
18
|
+
|| fileExists(join(ctx.root, 'vendor', 'velinstyle', 'velinstyle.min.css'));
|
|
19
|
+
if (dep || vendor) return [];
|
|
20
|
+
return [{
|
|
21
|
+
ruleId: 'consumer.velinstyle-installed',
|
|
22
|
+
category: 'consumer',
|
|
23
|
+
severity: 'warning',
|
|
24
|
+
message: '@birdapi/velinstyle not found in package.json or vendor/',
|
|
25
|
+
fix: 'npm i @birdapi/velinstyle or copy dist to vendor/',
|
|
26
|
+
}];
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
registerSecurityRule({
|
|
31
|
+
id: 'consumer.version-floor',
|
|
32
|
+
category: 'consumer',
|
|
33
|
+
severity: 'warning',
|
|
34
|
+
modes: ['consumer', 'audit'],
|
|
35
|
+
title: 'Minimum recommended version',
|
|
36
|
+
run(ctx) {
|
|
37
|
+
const pkg = readJson(join(ctx.root, 'package.json')) || {};
|
|
38
|
+
if (pkg.name === '@birdapi/velinstyle') return [];
|
|
39
|
+
const raw = pkg.dependencies?.['@birdapi/velinstyle'] || pkg.devDependencies?.['@birdapi/velinstyle'];
|
|
40
|
+
if (!raw) return [];
|
|
41
|
+
const m = String(raw).match(/(\d+)\.(\d+)\.(\d+)/);
|
|
42
|
+
if (!m) return [];
|
|
43
|
+
const [maj, min, pat] = m.slice(1).map(Number);
|
|
44
|
+
const tooOld = maj < 1 || (maj === 1 && min < 2) || (maj === 1 && min === 2 && pat < 2);
|
|
45
|
+
if (!tooOld) return [];
|
|
46
|
+
return [{
|
|
47
|
+
ruleId: 'consumer.version-floor',
|
|
48
|
+
category: 'consumer',
|
|
49
|
+
severity: 'warning',
|
|
50
|
+
message: `VelinStyle ${raw} is below recommended 1.2.2+`,
|
|
51
|
+
code: 'outdated',
|
|
52
|
+
fix: 'Upgrade to @birdapi/velinstyle@^1.2.2',
|
|
53
|
+
}];
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
registerSecurityRule({
|
|
58
|
+
id: 'consumer.noopener',
|
|
59
|
+
category: 'consumer',
|
|
60
|
+
severity: 'warning',
|
|
61
|
+
modes: ['consumer', 'scan', 'audit'],
|
|
62
|
+
title: 'target=_blank noopener',
|
|
63
|
+
run(ctx) {
|
|
64
|
+
const files = walkFiles(ctx.root, (n) => /\.html?$/i.test(n), 80);
|
|
65
|
+
const findings = [];
|
|
66
|
+
for (const abs of files) {
|
|
67
|
+
const t = readText(abs) || '';
|
|
68
|
+
const re = /target=["']_blank["'](?![^>]*rel=["'][^"']*noopener)/gi;
|
|
69
|
+
if (re.test(t)) {
|
|
70
|
+
findings.push({
|
|
71
|
+
ruleId: 'consumer.noopener',
|
|
72
|
+
category: 'consumer',
|
|
73
|
+
severity: 'warning',
|
|
74
|
+
message: 'target="_blank" without rel="noopener noreferrer"',
|
|
75
|
+
path: rel(ctx.root, abs),
|
|
76
|
+
fix: 'Add rel="noopener noreferrer"',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return findings.slice(0, 20);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
registerSecurityRule({
|
|
85
|
+
id: 'consumer.inline-script',
|
|
86
|
+
category: 'consumer',
|
|
87
|
+
severity: 'warning',
|
|
88
|
+
modes: ['consumer', 'scan', 'audit'],
|
|
89
|
+
title: 'Inline scripts',
|
|
90
|
+
run(ctx) {
|
|
91
|
+
const files = walkFiles(ctx.root, (n) => /\.html?$/i.test(n), 80);
|
|
92
|
+
const findings = [];
|
|
93
|
+
for (const abs of files) {
|
|
94
|
+
const t = readText(abs) || '';
|
|
95
|
+
if (/<script(?![^>]*\bsrc=)[^>]*>\s*[^<\s]/i.test(t)) {
|
|
96
|
+
findings.push({
|
|
97
|
+
ruleId: 'consumer.inline-script',
|
|
98
|
+
category: 'consumer',
|
|
99
|
+
severity: 'warning',
|
|
100
|
+
message: 'Inline <script> increases XSS surface',
|
|
101
|
+
path: rel(ctx.root, abs),
|
|
102
|
+
fix: 'Move to external module',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return findings.slice(0, 15);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
registerSecurityRule({
|
|
111
|
+
id: 'consumer.csp-meta',
|
|
112
|
+
category: 'consumer',
|
|
113
|
+
severity: 'info',
|
|
114
|
+
modes: ['consumer', 'scan', 'audit'],
|
|
115
|
+
title: 'CSP meta',
|
|
116
|
+
run(ctx) {
|
|
117
|
+
const files = walkFiles(ctx.root, (n) => /\.html?$/i.test(n), 40);
|
|
118
|
+
if (!files.length) return [];
|
|
119
|
+
const any = files.some((abs) => /Content-Security-Policy/i.test(readText(abs) || ''));
|
|
120
|
+
if (any) return [];
|
|
121
|
+
return [{
|
|
122
|
+
ruleId: 'consumer.csp-meta',
|
|
123
|
+
category: 'consumer',
|
|
124
|
+
severity: 'info',
|
|
125
|
+
message: 'No CSP meta found in scanned HTML',
|
|
126
|
+
fix: 'Add Content-Security-Policy header or meta',
|
|
127
|
+
}];
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
registerSecurityRule({
|
|
132
|
+
id: 'consumer.app-debug',
|
|
133
|
+
category: 'consumer',
|
|
134
|
+
severity: 'warning',
|
|
135
|
+
modes: ['consumer', 'audit', 'scan'],
|
|
136
|
+
title: 'Debug flags',
|
|
137
|
+
run(ctx) {
|
|
138
|
+
const findings = [];
|
|
139
|
+
for (const name of ['.env', '.env.example', 'config/app.php', 'velinstyle.config.js']) {
|
|
140
|
+
const t = readText(join(ctx.root, name));
|
|
141
|
+
if (t && /APP_DEBUG\s*=\s*true|debug\s*:\s*true/i.test(t)) {
|
|
142
|
+
findings.push({
|
|
143
|
+
ruleId: 'consumer.app-debug',
|
|
144
|
+
category: 'consumer',
|
|
145
|
+
severity: 'warning',
|
|
146
|
+
message: `Debug flag enabled in ${name}`,
|
|
147
|
+
path: name,
|
|
148
|
+
fix: 'Disable debug in production',
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return findings;
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
registerSecurityRule({
|
|
157
|
+
id: 'consumer.source-maps',
|
|
158
|
+
category: 'consumer',
|
|
159
|
+
severity: 'info',
|
|
160
|
+
modes: ['consumer', 'audit'],
|
|
161
|
+
title: 'Public source maps',
|
|
162
|
+
run(ctx) {
|
|
163
|
+
const maps = walkFiles(join(ctx.root, 'dist'), (n) => n.endsWith('.map'), 30);
|
|
164
|
+
if (!maps.length) return [];
|
|
165
|
+
return [{
|
|
166
|
+
ruleId: 'consumer.source-maps',
|
|
167
|
+
category: 'consumer',
|
|
168
|
+
severity: 'info',
|
|
169
|
+
message: `${maps.length} source map(s) under dist/ — ensure intentional for production`,
|
|
170
|
+
path: 'dist/',
|
|
171
|
+
}];
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { registerSecurityRule } from '../../registry.js';
|
|
2
|
+
import { fileExists, readJson, readText, walkFiles, rel } from '../../checks/fs.js';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
const KNOWN_POPULAR = [
|
|
6
|
+
'react', 'vue', 'lodash', 'express', 'webpack', 'typescript', 'eslint', 'vite',
|
|
7
|
+
'next', 'axios', 'jquery', 'moment', 'chalk', 'commander',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function levenshtein(a, b) {
|
|
11
|
+
const m = a.length;
|
|
12
|
+
const n = b.length;
|
|
13
|
+
const dp = Array.from({ length: m + 1 }, () => new Array(n + 1).fill(0));
|
|
14
|
+
for (let i = 0; i <= m; i++) dp[i][0] = i;
|
|
15
|
+
for (let j = 0; j <= n; j++) dp[0][j] = j;
|
|
16
|
+
for (let i = 1; i <= m; i++) {
|
|
17
|
+
for (let j = 1; j <= n; j++) {
|
|
18
|
+
dp[i][j] = Math.min(
|
|
19
|
+
dp[i - 1][j] + 1,
|
|
20
|
+
dp[i][j - 1] + 1,
|
|
21
|
+
dp[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return dp[m][n];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function registerDepsRules() {
|
|
29
|
+
registerSecurityRule({
|
|
30
|
+
id: 'deps.lockfile',
|
|
31
|
+
category: 'deps',
|
|
32
|
+
severity: 'warning',
|
|
33
|
+
modes: ['repo', 'consumer', 'deps', 'audit', 'publish'],
|
|
34
|
+
title: 'Lockfile present',
|
|
35
|
+
run(ctx) {
|
|
36
|
+
const ok =
|
|
37
|
+
fileExists(join(ctx.root, 'package-lock.json'))
|
|
38
|
+
|| fileExists(join(ctx.root, 'pnpm-lock.yaml'))
|
|
39
|
+
|| fileExists(join(ctx.root, 'yarn.lock'));
|
|
40
|
+
if (ok) return [];
|
|
41
|
+
return [{
|
|
42
|
+
ruleId: 'deps.lockfile',
|
|
43
|
+
category: 'deps',
|
|
44
|
+
severity: 'warning',
|
|
45
|
+
message: 'No lockfile found (package-lock / pnpm-lock / yarn.lock)',
|
|
46
|
+
code: 'no-lockfile',
|
|
47
|
+
fix: 'Commit a lockfile for reproducible installs',
|
|
48
|
+
}];
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
registerSecurityRule({
|
|
53
|
+
id: 'deps.lifecycle-hooks',
|
|
54
|
+
category: 'malware',
|
|
55
|
+
severity: 'warning',
|
|
56
|
+
modes: ['repo', 'consumer', 'deps', 'audit', 'publish', 'malware'],
|
|
57
|
+
title: 'Risky lifecycle scripts',
|
|
58
|
+
run(ctx) {
|
|
59
|
+
const pkg = readJson(join(ctx.root, 'package.json'));
|
|
60
|
+
if (!pkg?.scripts) return [];
|
|
61
|
+
const findings = [];
|
|
62
|
+
for (const hook of ['preinstall', 'install', 'postinstall', 'prepublish']) {
|
|
63
|
+
const s = pkg.scripts[hook];
|
|
64
|
+
if (!s) continue;
|
|
65
|
+
if (/curl\s|wget\s|Invoke-WebRequest|fetch\(['"]https?:/i.test(s)) {
|
|
66
|
+
findings.push({
|
|
67
|
+
ruleId: 'deps.lifecycle-hooks',
|
|
68
|
+
category: 'malware',
|
|
69
|
+
severity: 'error',
|
|
70
|
+
message: `Lifecycle script "${hook}" downloads remote content`,
|
|
71
|
+
path: 'package.json',
|
|
72
|
+
code: 'critical',
|
|
73
|
+
fix: 'Remove network installs from lifecycle hooks',
|
|
74
|
+
});
|
|
75
|
+
} else if (/node\s|npx\s|bash\s|sh\s/i.test(s)) {
|
|
76
|
+
findings.push({
|
|
77
|
+
ruleId: 'deps.lifecycle-hooks',
|
|
78
|
+
category: 'malware',
|
|
79
|
+
severity: 'info',
|
|
80
|
+
message: `Lifecycle script "${hook}" runs shell/node — review carefully`,
|
|
81
|
+
path: 'package.json',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return findings;
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
registerSecurityRule({
|
|
90
|
+
id: 'deps.engines',
|
|
91
|
+
category: 'deps',
|
|
92
|
+
severity: 'info',
|
|
93
|
+
modes: ['repo', 'consumer', 'deps', 'audit'],
|
|
94
|
+
title: 'Node engines field',
|
|
95
|
+
run(ctx) {
|
|
96
|
+
const pkg = readJson(join(ctx.root, 'package.json'));
|
|
97
|
+
if (pkg?.engines?.node) return [];
|
|
98
|
+
return [{
|
|
99
|
+
ruleId: 'deps.engines',
|
|
100
|
+
category: 'deps',
|
|
101
|
+
severity: 'info',
|
|
102
|
+
message: 'package.json missing engines.node',
|
|
103
|
+
path: 'package.json',
|
|
104
|
+
fix: 'Declare supported Node versions',
|
|
105
|
+
}];
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
registerSecurityRule({
|
|
110
|
+
id: 'deps.license-field',
|
|
111
|
+
category: 'deps',
|
|
112
|
+
severity: 'warning',
|
|
113
|
+
modes: ['repo', 'deps', 'audit', 'publish'],
|
|
114
|
+
title: 'License field',
|
|
115
|
+
run(ctx) {
|
|
116
|
+
const pkg = readJson(join(ctx.root, 'package.json'));
|
|
117
|
+
if (pkg?.license) return [];
|
|
118
|
+
return [{
|
|
119
|
+
ruleId: 'deps.license-field',
|
|
120
|
+
category: 'deps',
|
|
121
|
+
severity: 'warning',
|
|
122
|
+
message: 'package.json missing license field',
|
|
123
|
+
path: 'package.json',
|
|
124
|
+
code: 'deprecated',
|
|
125
|
+
fix: 'Set license (e.g. MIT)',
|
|
126
|
+
}];
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
registerSecurityRule({
|
|
131
|
+
id: 'deps.typosquat',
|
|
132
|
+
category: 'malware',
|
|
133
|
+
severity: 'warning',
|
|
134
|
+
modes: ['repo', 'consumer', 'deps', 'audit', 'malware'],
|
|
135
|
+
title: 'Typosquat heuristic',
|
|
136
|
+
run(ctx) {
|
|
137
|
+
const pkg = readJson(join(ctx.root, 'package.json'));
|
|
138
|
+
const names = Object.keys({ ...pkg?.dependencies, ...pkg?.devDependencies });
|
|
139
|
+
const findings = [];
|
|
140
|
+
for (const name of names) {
|
|
141
|
+
const base = name.includes('/') ? name.split('/').pop() : name;
|
|
142
|
+
for (const pop of KNOWN_POPULAR) {
|
|
143
|
+
const d = levenshtein(base.toLowerCase(), pop);
|
|
144
|
+
if (d === 1 && base.toLowerCase() !== pop) {
|
|
145
|
+
findings.push({
|
|
146
|
+
ruleId: 'deps.typosquat',
|
|
147
|
+
category: 'malware',
|
|
148
|
+
severity: 'warning',
|
|
149
|
+
message: `Package "${name}" is 1 edit from popular "${pop}" — verify intentional`,
|
|
150
|
+
path: 'package.json',
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return findings;
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
registerSecurityRule({
|
|
160
|
+
id: 'deps.deprecated-request',
|
|
161
|
+
category: 'deps',
|
|
162
|
+
severity: 'warning',
|
|
163
|
+
modes: ['repo', 'consumer', 'deps', 'audit'],
|
|
164
|
+
title: 'Known deprecated packages',
|
|
165
|
+
run(ctx) {
|
|
166
|
+
const pkg = readJson(join(ctx.root, 'package.json'));
|
|
167
|
+
const names = Object.keys({ ...pkg?.dependencies, ...pkg?.devDependencies });
|
|
168
|
+
const deprecated = ['request', 'node-uuid', 'crypto', 'gulp-util'];
|
|
169
|
+
return names
|
|
170
|
+
.filter((n) => deprecated.includes(n))
|
|
171
|
+
.map((n) => ({
|
|
172
|
+
ruleId: 'deps.deprecated-request',
|
|
173
|
+
category: 'deps',
|
|
174
|
+
severity: 'warning',
|
|
175
|
+
message: `Dependency "${n}" is widely considered deprecated`,
|
|
176
|
+
path: 'package.json',
|
|
177
|
+
code: 'deprecated',
|
|
178
|
+
fix: 'Replace with maintained alternative',
|
|
179
|
+
}));
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { registerSecretsRules } from './secrets/index.js';
|
|
2
|
+
import { registerDepsRules } from './deps/index.js';
|
|
3
|
+
import { registerCiRules } from './ci/index.js';
|
|
4
|
+
import { registerPublishRules } from './publish/index.js';
|
|
5
|
+
import { registerRepoRules } from './repo/index.js';
|
|
6
|
+
import { registerConsumerRules } from './consumer/index.js';
|
|
7
|
+
|
|
8
|
+
let loaded = false;
|
|
9
|
+
|
|
10
|
+
/** Idempotent: register all built-in Security Engine rules. */
|
|
11
|
+
export function loadBuiltinSecurityRules() {
|
|
12
|
+
if (loaded) return;
|
|
13
|
+
registerSecretsRules();
|
|
14
|
+
registerDepsRules();
|
|
15
|
+
registerCiRules();
|
|
16
|
+
registerPublishRules();
|
|
17
|
+
registerRepoRules();
|
|
18
|
+
registerConsumerRules();
|
|
19
|
+
loaded = true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function resetBuiltinSecurityRulesFlag() {
|
|
23
|
+
loaded = false;
|
|
24
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { registerSecurityRule } from '../../registry.js';
|
|
2
|
+
import { fileExists, readJson, readText } from '../../checks/fs.js';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
|
|
6
|
+
export function registerPublishRules() {
|
|
7
|
+
registerSecurityRule({
|
|
8
|
+
id: 'publish.readme',
|
|
9
|
+
category: 'publish',
|
|
10
|
+
severity: 'error',
|
|
11
|
+
modes: ['repo', 'publish', 'audit'],
|
|
12
|
+
title: 'README',
|
|
13
|
+
run(ctx) {
|
|
14
|
+
if (fileExists(join(ctx.root, 'README.md'))) return [];
|
|
15
|
+
return [{
|
|
16
|
+
ruleId: 'publish.readme',
|
|
17
|
+
category: 'publish',
|
|
18
|
+
severity: 'error',
|
|
19
|
+
message: 'README.md missing',
|
|
20
|
+
path: 'README.md',
|
|
21
|
+
}];
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
registerSecurityRule({
|
|
26
|
+
id: 'publish.changelog',
|
|
27
|
+
category: 'publish',
|
|
28
|
+
severity: 'error',
|
|
29
|
+
modes: ['repo', 'publish', 'audit'],
|
|
30
|
+
title: 'CHANGELOG',
|
|
31
|
+
run(ctx) {
|
|
32
|
+
if (fileExists(join(ctx.root, 'CHANGELOG.md'))) return [];
|
|
33
|
+
return [{
|
|
34
|
+
ruleId: 'publish.changelog',
|
|
35
|
+
category: 'publish',
|
|
36
|
+
severity: 'error',
|
|
37
|
+
message: 'CHANGELOG.md missing',
|
|
38
|
+
path: 'CHANGELOG.md',
|
|
39
|
+
}];
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
registerSecurityRule({
|
|
44
|
+
id: 'publish.security-md',
|
|
45
|
+
category: 'publish',
|
|
46
|
+
severity: 'error',
|
|
47
|
+
modes: ['repo', 'publish', 'audit'],
|
|
48
|
+
title: 'SECURITY.md',
|
|
49
|
+
run(ctx) {
|
|
50
|
+
if (fileExists(join(ctx.root, 'SECURITY.md'))) return [];
|
|
51
|
+
return [{
|
|
52
|
+
ruleId: 'publish.security-md',
|
|
53
|
+
category: 'publish',
|
|
54
|
+
severity: 'error',
|
|
55
|
+
message: 'SECURITY.md missing',
|
|
56
|
+
path: 'SECURITY.md',
|
|
57
|
+
}];
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
registerSecurityRule({
|
|
62
|
+
id: 'publish.license',
|
|
63
|
+
category: 'publish',
|
|
64
|
+
severity: 'error',
|
|
65
|
+
modes: ['repo', 'publish', 'audit'],
|
|
66
|
+
title: 'LICENSE',
|
|
67
|
+
run(ctx) {
|
|
68
|
+
const pkg = readJson(join(ctx.root, 'package.json')) || {};
|
|
69
|
+
if (fileExists(join(ctx.root, 'LICENSE')) || fileExists(join(ctx.root, 'LICENSE.md')) || pkg.license) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return [{
|
|
73
|
+
ruleId: 'publish.license',
|
|
74
|
+
category: 'publish',
|
|
75
|
+
severity: 'error',
|
|
76
|
+
message: 'LICENSE file / package.json license missing',
|
|
77
|
+
path: 'LICENSE',
|
|
78
|
+
}];
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
registerSecurityRule({
|
|
83
|
+
id: 'publish.release-notes',
|
|
84
|
+
category: 'publish',
|
|
85
|
+
severity: 'warning',
|
|
86
|
+
modes: ['repo', 'publish', 'audit'],
|
|
87
|
+
title: 'Release notes',
|
|
88
|
+
run(ctx) {
|
|
89
|
+
const pkg = readJson(join(ctx.root, 'package.json')) || {};
|
|
90
|
+
const v = pkg.version;
|
|
91
|
+
if (!v) return [];
|
|
92
|
+
const notes = fileExists(join(ctx.root, `RELEASE_NOTES_${v}.md`));
|
|
93
|
+
const cl = readText(join(ctx.root, 'CHANGELOG.md')) || '';
|
|
94
|
+
if (notes || cl.includes(`[${v}]`)) return [];
|
|
95
|
+
return [{
|
|
96
|
+
ruleId: 'publish.release-notes',
|
|
97
|
+
category: 'publish',
|
|
98
|
+
severity: 'warning',
|
|
99
|
+
message: `No RELEASE_NOTES_${v}.md and no CHANGELOG entry for [${v}]`,
|
|
100
|
+
fix: 'Add release notes before publish',
|
|
101
|
+
}];
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
registerSecurityRule({
|
|
106
|
+
id: 'publish.version-tag',
|
|
107
|
+
category: 'publish',
|
|
108
|
+
severity: 'warning',
|
|
109
|
+
modes: ['repo', 'publish', 'audit'],
|
|
110
|
+
title: 'Git tag matches version',
|
|
111
|
+
run(ctx) {
|
|
112
|
+
const pkg = readJson(join(ctx.root, 'package.json')) || {};
|
|
113
|
+
const v = pkg.version;
|
|
114
|
+
if (!v) return [];
|
|
115
|
+
try {
|
|
116
|
+
const tag = execSync(`git tag -l "v${v}"`, { cwd: ctx.root, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
117
|
+
if (tag) return [];
|
|
118
|
+
return [{
|
|
119
|
+
ruleId: 'publish.version-tag',
|
|
120
|
+
category: 'publish',
|
|
121
|
+
severity: 'warning',
|
|
122
|
+
message: `Git tag v${v} not found yet`,
|
|
123
|
+
fix: `Create annotated tag v${v} before npm publish from CI`,
|
|
124
|
+
}];
|
|
125
|
+
} catch {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
registerSecurityRule({
|
|
132
|
+
id: 'publish.clean-tree',
|
|
133
|
+
category: 'publish',
|
|
134
|
+
severity: 'warning',
|
|
135
|
+
modes: ['repo', 'publish', 'audit'],
|
|
136
|
+
title: 'Working tree clean',
|
|
137
|
+
run(ctx) {
|
|
138
|
+
try {
|
|
139
|
+
const dirty = execSync('git status --porcelain', { cwd: ctx.root, encoding: 'utf-8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
140
|
+
if (!dirty) return [];
|
|
141
|
+
return [{
|
|
142
|
+
ruleId: 'publish.clean-tree',
|
|
143
|
+
category: 'publish',
|
|
144
|
+
severity: 'warning',
|
|
145
|
+
message: 'Working tree has uncommitted changes',
|
|
146
|
+
fix: 'Commit or stash before release',
|
|
147
|
+
}];
|
|
148
|
+
} catch {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
registerSecurityRule({
|
|
155
|
+
id: 'publish.private-flag',
|
|
156
|
+
category: 'publish',
|
|
157
|
+
severity: 'error',
|
|
158
|
+
modes: ['repo', 'publish', 'audit'],
|
|
159
|
+
title: 'Not private',
|
|
160
|
+
run(ctx) {
|
|
161
|
+
const pkg = readJson(join(ctx.root, 'package.json')) || {};
|
|
162
|
+
if (pkg.private === true) {
|
|
163
|
+
return [{
|
|
164
|
+
ruleId: 'publish.private-flag',
|
|
165
|
+
category: 'publish',
|
|
166
|
+
severity: 'error',
|
|
167
|
+
message: 'package.json has "private": true — npm publish will fail',
|
|
168
|
+
path: 'package.json',
|
|
169
|
+
}];
|
|
170
|
+
}
|
|
171
|
+
return [];
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
registerSecurityRule({
|
|
176
|
+
id: 'publish.pack-dry-run',
|
|
177
|
+
category: 'publish',
|
|
178
|
+
severity: 'error',
|
|
179
|
+
modes: ['repo', 'publish', 'audit'],
|
|
180
|
+
title: 'npm pack dry-run',
|
|
181
|
+
run(ctx) {
|
|
182
|
+
if (!fileExists(join(ctx.root, 'package.json'))) {
|
|
183
|
+
return [{
|
|
184
|
+
ruleId: 'publish.pack-dry-run',
|
|
185
|
+
category: 'publish',
|
|
186
|
+
severity: 'warning',
|
|
187
|
+
message: 'package.json missing — cannot run npm pack --dry-run',
|
|
188
|
+
path: 'package.json',
|
|
189
|
+
}];
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
execSync('npm pack --dry-run', {
|
|
193
|
+
cwd: ctx.root,
|
|
194
|
+
encoding: 'utf-8',
|
|
195
|
+
timeout: 30_000,
|
|
196
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
197
|
+
});
|
|
198
|
+
return [];
|
|
199
|
+
} catch (err) {
|
|
200
|
+
const status = err?.status;
|
|
201
|
+
const stderr = String(err?.stderr || err?.message || '').trim().slice(0, 400);
|
|
202
|
+
if (err?.code === 'ENOENT') {
|
|
203
|
+
return [{
|
|
204
|
+
ruleId: 'publish.pack-dry-run',
|
|
205
|
+
category: 'publish',
|
|
206
|
+
severity: 'warning',
|
|
207
|
+
message: 'npm not available — skipped pack dry-run',
|
|
208
|
+
fix: 'Install npm or run pack dry-run on a machine with Node/npm',
|
|
209
|
+
}];
|
|
210
|
+
}
|
|
211
|
+
if (err?.killed || err?.signal === 'SIGTERM' || /ETIMEDOUT|timed out/i.test(String(err?.message))) {
|
|
212
|
+
return [{
|
|
213
|
+
ruleId: 'publish.pack-dry-run',
|
|
214
|
+
category: 'publish',
|
|
215
|
+
severity: 'warning',
|
|
216
|
+
message: 'npm pack --dry-run timed out',
|
|
217
|
+
fix: 'Retry with network available or inspect package files locally',
|
|
218
|
+
}];
|
|
219
|
+
}
|
|
220
|
+
return [{
|
|
221
|
+
ruleId: 'publish.pack-dry-run',
|
|
222
|
+
category: 'publish',
|
|
223
|
+
severity: status ? 'error' : 'warning',
|
|
224
|
+
message: `npm pack --dry-run failed${status != null ? ` (exit ${status})` : ''}${stderr ? `: ${stderr}` : ''}`,
|
|
225
|
+
fix: 'Fix pack errors (files, package.json) before publish',
|
|
226
|
+
}];
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
}
|