kryptheon 0.1.58 → 0.1.61
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/LICENSE +38 -38
- package/kryptheon-api.js +274 -14
- package/kryptheon-baselines.js +232 -232
- package/kryptheon-changes.js +222 -222
- package/kryptheon-code.js +13 -1
- package/kryptheon-dashboard.js +8 -2
- package/kryptheon-fonts-OFL.txt +98 -98
- package/kryptheon-keys.js +353 -353
- package/kryptheon-map.js +14 -4
- package/kryptheon-probe-reporter.js +29 -29
- package/kryptheon-probe.config.js +37 -37
- package/kryptheon-project.js +600 -600
- package/kryptheon-roles.js +114 -24
- package/kryptheon-selectors.js +301 -301
- package/kryptheon-store.js +334 -334
- package/kryptheon-testfiles.js +98 -98
- package/kryptheon-webhook.js +316 -68
- package/package.json +1 -1
- package/playwright.config.js +73 -73
package/kryptheon-map.js
CHANGED
|
@@ -61,7 +61,10 @@ const OTHER_FRAMEWORKS = /^(fastify|koa|@koa\/router|koa-router|hono|@hono\/hono
|
|
|
61
61
|
const IDENTITY_SEGS = /^(user|users|session|auth|actor|account|member|currentUser|identity|principal|claims|userId|user_id|uid|sub|me|profile|viewer|isAuthenticated|isLoggedIn|token|kauth|apiKey|api_key|tenant|org|workspace)$/;
|
|
62
62
|
const IDENTITY_NAMES = /^(user|currentUser|current_user|me|actor|member|account|profile|viewer|identity|principal|session|sessionUser|authUser|auth|claims)$/i;
|
|
63
63
|
// A cookie or header that says who is calling: a session token (sid, token) or, worse, the user id itself.
|
|
64
|
-
|
|
64
|
+
// a session cookie, not a bare id: its value is a secret only the caller holds
|
|
65
|
+
const SESSION_COOKIE = /^(?!.*(csrf|xsrf))(?:[a-z0-9]+[_.-])*(sid|session|sessionId|session_id|token|jwt|access_token|accessToken)$/i;
|
|
66
|
+
// the name may carry the app's own prefix: wayline_sid, app-session, myapp.token (round 26) - never a CSRF token
|
|
67
|
+
const COOKIE_IDENTITY = /^(?!.*(csrf|xsrf))(?:[a-z0-9]+[_.-])*(uid|user|userId|user_id|userid|id|sid|session|sessionId|session_id|token|auth|jwt|access_token|accessToken)$/i;
|
|
65
68
|
const HEADER_IDENTITY = /^x-(user|uid|user-id|userid|account|account-id|member|member-id|actor|actor-id)$/i;
|
|
66
69
|
// Of those, the ones that hold the bare id - nothing a server signed, so anyone can write another person's.
|
|
67
70
|
const BARE_ID = /^(uid|user|userId|user_id|userid|id)$/i;
|
|
@@ -644,12 +647,15 @@ function refText(p) {
|
|
|
644
647
|
return chain ? chain.join('.') : '(' + n.type + ')';
|
|
645
648
|
}
|
|
646
649
|
|
|
647
|
-
/**
|
|
650
|
+
/**
|
|
651
|
+
* '/api' + '/x/' -> '/api/x'. A parameter written with a pattern is the same parameter: /work-orders/:id(\d+) is
|
|
652
|
+
* /work-orders/:id (round 27: the detail route kept its pattern and was never aimed).
|
|
653
|
+
*/
|
|
648
654
|
function joinPath(a, b) {
|
|
649
655
|
const x = (a || '').replace(/\/+$/, '');
|
|
650
656
|
const y = (b || '/').startsWith('/') ? b || '/' : '/' + b;
|
|
651
657
|
const out = (x + (y === '/' ? '' : y)) || '/';
|
|
652
|
-
return out.replace(/\/{2,}/g, '/');
|
|
658
|
+
return out.replace(/\/{2,}/g, '/').replace(/(:[A-Za-z_]\w*)\((?:[^()\\]|\\.)*\)/g, '$1');
|
|
653
659
|
}
|
|
654
660
|
|
|
655
661
|
/** Whether middleware used at `prefix` runs for a request to `full`. */
|
|
@@ -1515,6 +1521,9 @@ function sourceReader(ctx, fnRef, env) {
|
|
|
1515
1521
|
if (!chain) return null;
|
|
1516
1522
|
if (locals.has(chain[0])) return locals.get(chain[0]);
|
|
1517
1523
|
if (reqName && chain[0] === reqName) {
|
|
1524
|
+
// the caller's own session cookie: a token nobody else holds, so a row found by it is the caller's own
|
|
1525
|
+
// (round 26: DELETE FROM app_sessions WHERE session_token = req.cookies.wayline_sid). A bare id (uid) is not.
|
|
1526
|
+
if (/^(cookies|signedCookies)$/.test(chain[1] || '') && chain[2] && SESSION_COOKIE.test(chain[2])) return 'identity';
|
|
1518
1527
|
if (/^(body|query|params|headers|cookies|files|file|nextUrl|url)$/.test(chain[1] || '')) return 'client';
|
|
1519
1528
|
if (chain[1] && IDENTITY_SEGS.test(chain[1])) return 'identity';
|
|
1520
1529
|
if (/^(db|client|tx)$/.test(chain[1] || '')) return null;
|
|
@@ -2007,7 +2016,8 @@ function scopeVerdict(mod, line, st, filters, insertCols, schema, via, partlyUnr
|
|
|
2007
2016
|
const tenantList = all.filter((f) => TENANT_COLS.test(f.col) || (TENANT_TABLES.test(table) && f.col === 'id'));
|
|
2008
2017
|
const list = tenantList.length ? Array.from(new Set(tenantList.concat(all.filter(viaRow)))) : all;
|
|
2009
2018
|
const cols = (fs2) => Array.from(new Set(fs2.map((f) => f.col))).join(', ');
|
|
2010
|
-
|
|
2019
|
+
// a session or token column found by the caller's own session is the caller's own row too
|
|
2020
|
+
const byIdentity = list.filter((f) => (scopeCol(f.col) || /(^|_)(session|token|sid)(_?(id|hash|token))?$/i.test(f.col)) && f.src === 'identity');
|
|
2011
2021
|
const byScopedRow = list.filter((f) => viaRow(f) && f.row.status === STATUS.DETECTED);
|
|
2012
2022
|
const byClient = list.filter((f) => scopeCol(f.col) && f.src === 'client');
|
|
2013
2023
|
const byOpenRow = list.filter((f) => viaRow(f) && f.row.status === STATUS.NOT);
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// Says one line per probe run as it ends, in a form kryptheon-probe.js reads
|
|
2
|
-
// back and turns into words: "KXPROBE <done> <total> <id> <status>". Nothing
|
|
3
|
-
// else - a probe that fails is usually the app refusing a bad value, and a
|
|
4
|
-
// failure report for it would say the opposite of what happened.
|
|
5
|
-
|
|
6
|
-
class ProbeReporter {
|
|
7
|
-
onBegin(config, suite) {
|
|
8
|
-
this.total = suite.allTests().length;
|
|
9
|
-
this.done = 0;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
onTestEnd(test, result) {
|
|
13
|
-
this.done += 1;
|
|
14
|
-
const id = String(test.location.file).replace(/^.*[\\/]/, '').replace(/\.kxprobe\.js$/, '');
|
|
15
|
-
console.log('KXPROBE ' + this.done + ' ' + this.total + ' ' + id + ' ' + result.status);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
onError(error) {
|
|
19
|
-
// The run itself could not start - a broken copy, a missing browser.
|
|
20
|
-
const text = String((error && error.message) || error).split(/\r?\n/)[0];
|
|
21
|
-
console.log('KXPROBE-ERROR ' + text.slice(0, 300));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
printsToStdio() {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = ProbeReporter;
|
|
1
|
+
// Says one line per probe run as it ends, in a form kryptheon-probe.js reads
|
|
2
|
+
// back and turns into words: "KXPROBE <done> <total> <id> <status>". Nothing
|
|
3
|
+
// else - a probe that fails is usually the app refusing a bad value, and a
|
|
4
|
+
// failure report for it would say the opposite of what happened.
|
|
5
|
+
|
|
6
|
+
class ProbeReporter {
|
|
7
|
+
onBegin(config, suite) {
|
|
8
|
+
this.total = suite.allTests().length;
|
|
9
|
+
this.done = 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
onTestEnd(test, result) {
|
|
13
|
+
this.done += 1;
|
|
14
|
+
const id = String(test.location.file).replace(/^.*[\\/]/, '').replace(/\.kxprobe\.js$/, '');
|
|
15
|
+
console.log('KXPROBE ' + this.done + ' ' + this.total + ' ' + id + ' ' + result.status);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onError(error) {
|
|
19
|
+
// The run itself could not start - a broken copy, a missing browser.
|
|
20
|
+
const text = String((error && error.message) || error).split(/\r?\n/)[0];
|
|
21
|
+
console.log('KXPROBE-ERROR ' + text.slice(0, 300));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
printsToStdio() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = ProbeReporter;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
// The Playwright config for probe copies (kryptheon-probe.js). Kept apart from
|
|
3
|
-
// playwright.config.js on purpose: probes live in the store, not in tests/;
|
|
4
|
-
// they report through their own reporter; and their screenshots and traces
|
|
5
|
-
// go to a folder of their own - Playwright empties its output folder on every
|
|
6
|
-
// run, and the last check's evidence must not be wiped by a probe.
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const { defineConfig } = require('@playwright/test');
|
|
9
|
-
|
|
10
|
-
const PACKAGE_DIR = __dirname;
|
|
11
|
-
const USER_DIR = process.cwd();
|
|
12
|
-
const PROBE_DIR = process.env.KRYPTHEON_PROBE_DIR || path.join(USER_DIR, 'tests');
|
|
13
|
-
|
|
14
|
-
// The same .env reading as playwright.config.js, for the same reasons.
|
|
15
|
-
const secrets = require(path.join(PACKAGE_DIR, 'kryptheon-secrets.js'));
|
|
16
|
-
const values = secrets.readEnvFile(path.join(USER_DIR, '.env'));
|
|
17
|
-
for (const name of Object.keys(values)) {
|
|
18
|
-
if (!secrets.isSet(process.env[name])) process.env[name] = values[name];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = defineConfig({
|
|
22
|
-
testDir: PROBE_DIR,
|
|
23
|
-
testMatch: ['**/*.kxprobe.js'],
|
|
24
|
-
outputDir: path.join(PROBE_DIR, 'output'),
|
|
25
|
-
fullyParallel: false,
|
|
26
|
-
workers: 1,
|
|
27
|
-
retries: 0,
|
|
28
|
-
// Room for the gap before each run and for opening the page again after it.
|
|
29
|
-
timeout: 60000,
|
|
30
|
-
reporter: [[path.join(PACKAGE_DIR, 'kryptheon-probe-reporter.js')]],
|
|
31
|
-
use: {
|
|
32
|
-
headless: true,
|
|
33
|
-
channel: 'chromium',
|
|
34
|
-
screenshot: 'off',
|
|
35
|
-
trace: 'off',
|
|
36
|
-
},
|
|
37
|
-
});
|
|
1
|
+
// @ts-check
|
|
2
|
+
// The Playwright config for probe copies (kryptheon-probe.js). Kept apart from
|
|
3
|
+
// playwright.config.js on purpose: probes live in the store, not in tests/;
|
|
4
|
+
// they report through their own reporter; and their screenshots and traces
|
|
5
|
+
// go to a folder of their own - Playwright empties its output folder on every
|
|
6
|
+
// run, and the last check's evidence must not be wiped by a probe.
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const { defineConfig } = require('@playwright/test');
|
|
9
|
+
|
|
10
|
+
const PACKAGE_DIR = __dirname;
|
|
11
|
+
const USER_DIR = process.cwd();
|
|
12
|
+
const PROBE_DIR = process.env.KRYPTHEON_PROBE_DIR || path.join(USER_DIR, 'tests');
|
|
13
|
+
|
|
14
|
+
// The same .env reading as playwright.config.js, for the same reasons.
|
|
15
|
+
const secrets = require(path.join(PACKAGE_DIR, 'kryptheon-secrets.js'));
|
|
16
|
+
const values = secrets.readEnvFile(path.join(USER_DIR, '.env'));
|
|
17
|
+
for (const name of Object.keys(values)) {
|
|
18
|
+
if (!secrets.isSet(process.env[name])) process.env[name] = values[name];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = defineConfig({
|
|
22
|
+
testDir: PROBE_DIR,
|
|
23
|
+
testMatch: ['**/*.kxprobe.js'],
|
|
24
|
+
outputDir: path.join(PROBE_DIR, 'output'),
|
|
25
|
+
fullyParallel: false,
|
|
26
|
+
workers: 1,
|
|
27
|
+
retries: 0,
|
|
28
|
+
// Room for the gap before each run and for opening the page again after it.
|
|
29
|
+
timeout: 60000,
|
|
30
|
+
reporter: [[path.join(PACKAGE_DIR, 'kryptheon-probe-reporter.js')]],
|
|
31
|
+
use: {
|
|
32
|
+
headless: true,
|
|
33
|
+
channel: 'chromium',
|
|
34
|
+
screenshot: 'off',
|
|
35
|
+
trace: 'off',
|
|
36
|
+
},
|
|
37
|
+
});
|