@reliabilityworks/core 0.4.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reliabilityworks/core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -0,0 +1,66 @@
1
+ export const sveltekitRulesFixture = {
2
+ note: 'This file is a fixture used by VibeSec tests.',
3
+ }
4
+
5
+ export const sveltekitSecurityFixtures = [
6
+ "throw redirect(302, url.searchParams.get('next'))",
7
+ "redirect(301, url.searchParams.get('next'))",
8
+ "redirect(302, url.searchParams.get('next'))",
9
+ "cookies.set('session', token)",
10
+ "cookies.set('session', token, { secure: false, httpOnly: false, sameSite: 'none', domain: '.example.com', path: '/' })",
11
+ "Content-Security-Policy', \"script-src 'self' 'unsafe-inline'\"",
12
+ "Content-Security-Policy', \"script-src 'self' 'unsafe-eval'\"",
13
+ 'X-Powered-By',
14
+ "'http://example.com'",
15
+ "process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'",
16
+ 'rejectUnauthorized: false',
17
+ 'http://localhost',
18
+ '169.254.169.254',
19
+ "fetch(url.searchParams.get('url'))",
20
+ 'path.join(userInput)',
21
+ "readFile(url.searchParams.get('path'))",
22
+ "writeFile(url.searchParams.get('path'))",
23
+ 'eval(userInput)',
24
+ "new Function('return 1')()",
25
+ "exec('id')",
26
+ "execSync('id')",
27
+ "spawn('sh', ['-c', 'id'])",
28
+ "spawnSync('sh', ['-c', 'id'])",
29
+ "fork('worker.js')",
30
+ "createHash('md5')",
31
+ "createHash('sha1')",
32
+ 'Math.random()',
33
+ "cookieParser('super-secret-cookie-parser')",
34
+ "SESSION_SECRET = 'hardcoded-session-secret'",
35
+ "jwt.sign(payload, 'super-secret-jwt')",
36
+ "algorithms: ['none']",
37
+ 'bcrypt.hash(password, 10)',
38
+ 'password === input',
39
+ 'SELECT * FROM users + req.query.id',
40
+ '$where',
41
+ "new RegExp(url.searchParams.get('q'))",
42
+ '{@html content}',
43
+ 'text/html',
44
+ "Access-Control-Allow-Origin', '*'",
45
+ "Access-Control-Allow-Headers', '*'",
46
+ "Access-Control-Allow-Methods', '*'",
47
+ 'credentials: true',
48
+ 'debug: true',
49
+ 'console.log(process.env.SECRET)',
50
+ "authorization console.log('leak')",
51
+ 'console.log(await request.json())',
52
+ 'console.log(request.headers)',
53
+ 'JSON.parse(await request.text())',
54
+ 'xml2js',
55
+ 'graphql-playground',
56
+ 'rateLimit()',
57
+ 'csrf: false',
58
+ 'upload.any()',
59
+ '"/tmp/uploads"',
60
+ "{ headers: { Location: url.searchParams.get('next') } }",
61
+ ].join('\n')
62
+
63
+ export const sveltekitTemplateInterpolationFixture = "${url.searchParams.get('q')}"
64
+
65
+ export const sveltekitSqlTemplateInterpolationFixture =
66
+ 'SELECT * FROM users WHERE id = ${userInput}'
@@ -0,0 +1,29 @@
1
+ const assert = require('node:assert/strict')
2
+ const fs = require('node:fs/promises')
3
+ const path = require('node:path')
4
+ const test = require('node:test')
5
+
6
+ const { scanProject } = require('../dist/index.js')
7
+
8
+ test('sveltekit ruleset has fixture coverage', async () => {
9
+ const fixtureRoot = path.join(__dirname, 'fixtures', 'monorepo', 'apps', 'kit')
10
+ const rulesPath = path.join(__dirname, '..', '..', 'rulesets', 'sveltekit', 'rules.json')
11
+
12
+ const raw = await fs.readFile(rulesPath, 'utf8')
13
+ const rules = JSON.parse(raw)
14
+
15
+ assert.ok(Array.isArray(rules))
16
+ assert.ok(rules.length >= 60, `Expected at least 60 sveltekit rules, got ${rules.length}`)
17
+
18
+ const expectedIds = rules.map((r) => r.id)
19
+ const result = await scanProject({
20
+ rootDir: fixtureRoot,
21
+ pathBaseDir: fixtureRoot,
22
+ additionalRules: rules,
23
+ })
24
+
25
+ const foundIds = new Set(result.findings.map((finding) => finding.ruleId))
26
+ const missing = expectedIds.filter((id) => !foundIds.has(id))
27
+
28
+ assert.equal(missing.length, 0, `Missing sveltekit fixture coverage for: ${missing.join(', ')}`)
29
+ })