@nuxtjp/dependency-security 0.1.0 → 0.1.2
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.md +7 -4
- package/dependency-security.check.cjs +2 -3
- package/package.json +13 -7
- package/project.mjs +7 -1
- package/resolved-dependency.cjs +2 -2
- package/resolved-dependency.d.cts +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ It does not inspect arbitrary source, monitor endpoints, install dependencies,
|
|
|
7
7
|
contact a registry or silently modify a project during installation.
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
|
-
pnpm add -D @nuxtjp/dependency-security
|
|
10
|
+
pnpm add -D @nuxtjp/dependency-security
|
|
11
11
|
pnpm exec nuxtjp-security-config --project-root . --apply
|
|
12
12
|
pnpm install --no-frozen-lockfile
|
|
13
13
|
pnpm install --frozen-lockfile
|
|
@@ -15,9 +15,12 @@ pnpm exec nuxtjp-security-check --project-root .
|
|
|
15
15
|
pnpm audit --json
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
The preset requires an installed Nuxt host with the selected braces
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
The preset requires an installed Nuxt host with the selected braces and node-forge
|
|
19
|
+
targets. The simple-git compatibility patch applies only when that dependency is
|
|
20
|
+
active. Newer DevTools no longer needs it; absence is not a reason to install an
|
|
21
|
+
unused Git process library. Present targets still require the reviewed fixed
|
|
22
|
+
versions and malformed/escaping graphs fail closed. A bare core-only library
|
|
23
|
+
graph does not need these backports.
|
|
21
24
|
Use an initial install with `--ignore-scripts` before configuring a new host.
|
|
22
25
|
|
|
23
26
|
Commit the generated `.nuxtjp-security` patches, manifest and lockfile. Run the
|
|
@@ -52,8 +52,7 @@ test('active dependency graph uses every required upstream security version', ()
|
|
|
52
52
|
const policy = JSON.parse(fs.readFileSync(path.join(__dirname, 'dependency-versions.json'), 'utf8'));
|
|
53
53
|
const { installedDependencies } = require('./resolved-dependency.cjs');
|
|
54
54
|
for (const [name, version] of Object.entries(policy.overrides)) {
|
|
55
|
-
const matches = installedDependencies(process.cwd(), name);
|
|
56
|
-
assert.ok(matches.length > 0, 'Required dependency is absent: ' + name);
|
|
55
|
+
const matches = installedDependencies(process.cwd(), name, undefined, { allowMissing: true });
|
|
57
56
|
for (const manifest of matches) assert.equal(JSON.parse(fs.readFileSync(manifest, 'utf8')).version, version, name);
|
|
58
57
|
}
|
|
59
58
|
});
|
|
@@ -62,7 +61,7 @@ test('active dependency graph uses every required upstream security version', ()
|
|
|
62
61
|
test('fixed simple-git retains named and legacy ESM factory exports', async () => {
|
|
63
62
|
const { pathToFileURL } = require('node:url');
|
|
64
63
|
const { installedDependencies } = require('./resolved-dependency.cjs');
|
|
65
|
-
for (const manifest of installedDependencies(process.cwd(), 'simple-git', '4.0.2')) {
|
|
64
|
+
for (const manifest of installedDependencies(process.cwd(), 'simple-git', '4.0.2', { allowMissing: true })) {
|
|
66
65
|
const module = await import(pathToFileURL(path.join(path.dirname(manifest), 'dist/index.mjs')).href);
|
|
67
66
|
assert.equal(typeof module.simpleGit, 'function');
|
|
68
67
|
assert.equal(module.default, module.simpleGit);
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjp/dependency-security",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Explicit pnpm backport configuration and active dependency regression checks without Nuxt peers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=22.19.0"
|
|
9
9
|
},
|
|
10
|
-
"packageManager": "pnpm@10.29.3",
|
|
11
10
|
"repository": {
|
|
12
11
|
"type": "git",
|
|
13
12
|
"url": "git+https://github.com/nuxtjp/nuxtjp-ui.git",
|
|
@@ -48,13 +47,20 @@
|
|
|
48
47
|
"nuxtjp-security-config": "./apply.mjs",
|
|
49
48
|
"nuxtjp-security-check": "./check.mjs"
|
|
50
49
|
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"typescript": "5.9.3",
|
|
52
|
+
"@types/node": "24.12.0"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"dependency-security",
|
|
56
|
+
"supply-chain-security",
|
|
57
|
+
"pnpm",
|
|
58
|
+
"security",
|
|
59
|
+
"nuxt"
|
|
60
|
+
],
|
|
51
61
|
"scripts": {
|
|
52
62
|
"build": "node --check index.mjs && node --check project.mjs && node --check apply.mjs && node --check check.mjs && node --check resolved-dependency.cjs",
|
|
53
63
|
"test": "node --test test/*.test.mjs",
|
|
54
64
|
"typecheck": "tsc --strict --noEmit --module NodeNext --moduleResolution NodeNext --target ES2022 test/public-types.mts"
|
|
55
|
-
},
|
|
56
|
-
"devDependencies": {
|
|
57
|
-
"typescript": "5.9.3",
|
|
58
|
-
"@types/node": "24.12.0"
|
|
59
65
|
}
|
|
60
|
-
}
|
|
66
|
+
}
|
package/project.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { existsSync, lstatSync, readFileSync, mkdirSync, writeFileSync, renameSync, unlinkSync, realpathSync } from 'node:fs'
|
|
3
3
|
import { join, resolve } from 'node:path'
|
|
4
4
|
import { randomUUID } from 'node:crypto'
|
|
5
|
+
import resolver from './resolved-dependency.cjs'
|
|
5
6
|
|
|
6
7
|
const patches = ['braces@3.0.3', 'node-forge@1.4.0', 'simple-git@4.0.2']
|
|
7
8
|
function regular(path) {
|
|
@@ -50,6 +51,7 @@ export function applySecurityPatches(project, source) {
|
|
|
50
51
|
if (existsSync(dir) && (lstatSync(dir).isSymbolicLink() || !lstatSync(dir).isDirectory())) {
|
|
51
52
|
throw new Error('Security patch directory must be a real directory')
|
|
52
53
|
}
|
|
54
|
+
const activeSimpleGit = resolver.installedDependencies(root, 'simple-git', undefined, { allowMissing: true }).length > 0
|
|
53
55
|
const inputs = patches.map(name => {
|
|
54
56
|
const relative = `.nuxtjp-security/${name.replace('@', '-')}.patch`
|
|
55
57
|
if (existing[name] !== undefined && existing[name] !== relative) {
|
|
@@ -60,11 +62,15 @@ export function applySecurityPatches(project, source) {
|
|
|
60
62
|
if (existsSync(target) && !regular(target).equals(bytes)) {
|
|
61
63
|
throw new Error('An existing patch differs; no files were overwritten')
|
|
62
64
|
}
|
|
63
|
-
return { name, relative, bytes, target }
|
|
65
|
+
return { name, relative, bytes, target, required: name !== 'simple-git@4.0.2' || activeSimpleGit }
|
|
64
66
|
})
|
|
65
67
|
if (!readFileSync(manifest).equals(original)) throw new Error('Manifest changed during preparation')
|
|
66
68
|
mkdirSync(dir, { recursive: true })
|
|
67
69
|
for (const patch of inputs) {
|
|
70
|
+
if (!patch.required) {
|
|
71
|
+
delete existing[patch.name]
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
68
74
|
if (!existsSync(patch.target)) writeFileSync(patch.target, patch.bytes, { flag: 'wx' })
|
|
69
75
|
existing[patch.name] = patch.relative
|
|
70
76
|
}
|
package/resolved-dependency.cjs
CHANGED
|
@@ -3,7 +3,7 @@ const fs = require('node:fs');
|
|
|
3
3
|
const path = require('node:path');
|
|
4
4
|
const { createRequire } = require('node:module');
|
|
5
5
|
|
|
6
|
-
function installedDependencies(root, target, version) {
|
|
6
|
+
function installedDependencies(root, target, version, options = {}) {
|
|
7
7
|
root = fs.realpathSync(root);
|
|
8
8
|
const pending = [path.join(root, 'package.json')];
|
|
9
9
|
const seen = new Set();
|
|
@@ -37,7 +37,7 @@ function installedDependencies(root, target, version) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
if (found.size === 0) throw new Error('Dependency not present in the installed application graph');
|
|
40
|
+
if (found.size === 0 && options.allowMissing !== true) throw new Error('Dependency not present in the installed application graph');
|
|
41
41
|
return [...found].sort();
|
|
42
42
|
}
|
|
43
43
|
module.exports = { installedDependencies };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Traverse only the selected installed application graph, with a finite budget. */
|
|
2
|
-
export function installedDependencies(root: string, target: string, version?: string): string[];
|
|
2
|
+
export function installedDependencies(root: string, target: string, version?: string, options?: { allowMissing?: boolean }): string[];
|