kryptheon 0.1.53 → 0.1.54
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/bin/kryptheon.js +43 -3
- package/kryptheon-authz.js +8 -0
- package/kryptheon-dashboard-page.js +13 -7
- package/kryptheon-dashboard.js +20 -6
- package/kryptheon-heal.js +18 -0
- package/kryptheon-payments-run.js +42 -15
- package/kryptheon-payments.js +52 -10
- package/kryptheon-probe-fixture.js +15 -1
- package/kryptheon-probe.js +2 -3
- package/kryptheon-reliability.js +44 -7
- package/kryptheon-replay.js +1 -0
- package/kryptheon-roles.js +1332 -0
- package/package.json +7 -4
package/bin/kryptheon.js
CHANGED
|
@@ -107,8 +107,10 @@ function usage() {
|
|
|
107
107
|
console.log(' npx kryptheon code read your frontend code for text inserted as HTML');
|
|
108
108
|
console.log(' npx kryptheon edge try unusual values in your recorded forms (adds test data; asks first)');
|
|
109
109
|
console.log(' npx kryptheon reliability replay each flow 3 times, double-click what saves (adds test data; asks first)');
|
|
110
|
+
console.log(' npx kryptheon roles every recorded action tried as each account, and across organizations (needs permissions-policy.json; asks first)');
|
|
110
111
|
console.log(' npx kryptheon payments one test payment, its webhook sent again: given twice? (asks first)');
|
|
111
112
|
console.log(' ... --app <url> --port <n> --schema <name> --test-mode (database: KRYPTHEON_DATABASE_URL)');
|
|
113
|
+
console.log(' ... --signature-header <name> your app signs its own webhooks in this header (not Razorpay or Stripe)');
|
|
112
114
|
console.log(' npx kryptheon dashboard the page above (also: npx kryptheon, in a terminal)');
|
|
113
115
|
console.log('');
|
|
114
116
|
console.log(' add --quiet to check for one line when everything passes');
|
|
@@ -2156,6 +2158,13 @@ const PROBE_CHECKS = {
|
|
|
2156
2158
|
// It types nothing of its own, so nothing it saves carries the marker.
|
|
2157
2159
|
words: { marker: false },
|
|
2158
2160
|
},
|
|
2161
|
+
roles: {
|
|
2162
|
+
module: 'kryptheon-roles.js',
|
|
2163
|
+
// Read from the module when asked, so a command that never needs this check never loads it.
|
|
2164
|
+
get what() { return require(path.join(PACKAGE_DIR, 'kryptheon-roles.js')).WHAT; },
|
|
2165
|
+
get none() { return require(path.join(PACKAGE_DIR, 'kryptheon-roles.js')).NONE; },
|
|
2166
|
+
get words() { return require(path.join(PACKAGE_DIR, 'kryptheon-roles.js')).WORDS; },
|
|
2167
|
+
},
|
|
2159
2168
|
};
|
|
2160
2169
|
|
|
2161
2170
|
function probeModule(check) {
|
|
@@ -2172,6 +2181,17 @@ async function probeCommand(check, args) {
|
|
|
2172
2181
|
const runner = probeModule(check);
|
|
2173
2182
|
const probe = require(path.join(PACKAGE_DIR, 'kryptheon-probe.js'));
|
|
2174
2183
|
const { flows } = probeFlows();
|
|
2184
|
+
// Some checks need something from the person first (the roles check: the
|
|
2185
|
+
// permissions file). Said before anything is asked or run.
|
|
2186
|
+
if (typeof runner.preflight === 'function') {
|
|
2187
|
+
const pre = runner.preflight(USER_DIR);
|
|
2188
|
+
if (!pre.ok) {
|
|
2189
|
+
console.log('');
|
|
2190
|
+
for (const line of pre.lines) console.log(' ' + line);
|
|
2191
|
+
console.log('');
|
|
2192
|
+
return 2;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2175
2195
|
if (!flows.length) {
|
|
2176
2196
|
console.log('');
|
|
2177
2197
|
console.log(' ' + PROBE_CHECKS[check].none);
|
|
@@ -2180,6 +2200,15 @@ async function probeCommand(check, args) {
|
|
|
2180
2200
|
return 2;
|
|
2181
2201
|
}
|
|
2182
2202
|
const addresses = probe.knownAddresses(USER_DIR, flows.map((f) => f.source));
|
|
2203
|
+
// A check that sends what must be refused runs only against this computer.
|
|
2204
|
+
if (runner.LOCAL_ONLY && probe.liveLooking(addresses).length) {
|
|
2205
|
+
console.log('');
|
|
2206
|
+
console.log(' Your recordings open ' + probe.liveLooking(addresses).join(', ') + ', which is not this computer.');
|
|
2207
|
+
console.log(' This check sends requests that must be refused, so it runs only against your app on this computer (localhost or 127.0.0.1).');
|
|
2208
|
+
console.log(' Start a copy of your app here, record against that, and run it again.');
|
|
2209
|
+
console.log('');
|
|
2210
|
+
return 2;
|
|
2211
|
+
}
|
|
2183
2212
|
const confirmed = await probeConsent(PROBE_CHECKS[check].what, addresses, args.includes('--yes'), PROBE_CHECKS[check].words);
|
|
2184
2213
|
if (!confirmed) return 2;
|
|
2185
2214
|
if (!ensureBrowser()) return 2;
|
|
@@ -2229,6 +2258,7 @@ async function paymentsCommand(args) {
|
|
|
2229
2258
|
database: process.env.KRYPTHEON_DATABASE_URL || null,
|
|
2230
2259
|
yes: args.includes('--yes'),
|
|
2231
2260
|
testMode: args.includes('--test-mode'),
|
|
2261
|
+
signatureHeader: flagValue(args, '--signature-header'),
|
|
2232
2262
|
ask: (question) => (process.stdin.isTTY ? askLine(' ' + question) : Promise.resolve('')),
|
|
2233
2263
|
say: (line) => console.log(line ? ' ' + line : ''),
|
|
2234
2264
|
stopped: () => stopped,
|
|
@@ -2684,7 +2714,8 @@ async function probeRecheckCommand(target, options) {
|
|
|
2684
2714
|
const addresses = probe.knownAddresses(USER_DIR, flow ? [flow.source] : []);
|
|
2685
2715
|
const name = '"' + (flow ? flow.title : file) + '"';
|
|
2686
2716
|
const what = 'Re-check ' + target.id + ': ' + (
|
|
2687
|
-
target.check === '
|
|
2717
|
+
target.check === 'roles' ? 'tries ' + target.where + ' again as every account, from the requests the last press learned. It changes data in your app (a refused account that gets through) and puts back what it can.'
|
|
2718
|
+
: target.check === 'edge' ? 'replays ' + name + ' as recorded, then once more with the value that found this. Two runs.'
|
|
2688
2719
|
: target.kind === 'flaky' ? 'replays ' + name + ' five times. It is fixed only if all five work.'
|
|
2689
2720
|
: target.kind === 'phone' ? 'replays ' + name + ' once, then once more at phone size, clicking every button with saving blocked. Two runs.'
|
|
2690
2721
|
: target.kind === 'race' ? 'replays ' + name + ' once, then once more with this save sent twice at the same moment. Two runs.'
|
|
@@ -2959,6 +2990,13 @@ async function probeFromDashboard(id, say, control, confirmed) {
|
|
|
2959
2990
|
if (!PROBE_CHECKS[id]) return { ok: false, why: '"' + id + '" cannot be run from the dashboard' };
|
|
2960
2991
|
const runner = probeModule(id);
|
|
2961
2992
|
const { flows } = probeFlows();
|
|
2993
|
+
if (typeof runner.preflight === 'function') {
|
|
2994
|
+
const pre = runner.preflight(USER_DIR);
|
|
2995
|
+
if (!pre.ok) {
|
|
2996
|
+
for (const line of pre.lines) say(line);
|
|
2997
|
+
return { ok: false, why: pre.lines[0] };
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
2962
3000
|
if (!flows.length) return { ok: false, why: 'there is no recording that can be replayed - record one of your flows' };
|
|
2963
3001
|
if (!ensureBrowser()) return { ok: false, why: 'the browser could not be downloaded' };
|
|
2964
3002
|
const report = await runner.run(USER_DIR, flows, {
|
|
@@ -2986,7 +3024,7 @@ async function probeRecheck(id, say, control, confirmed) {
|
|
|
2986
3024
|
if (!target) return null;
|
|
2987
3025
|
const runner = probeModule(target.check);
|
|
2988
3026
|
const { flows } = probeFlows();
|
|
2989
|
-
if (!ensureBrowser()) return { target: target, verdict: 'could not confirm', why: 'the browser could not be downloaded', newProblems: [] };
|
|
3027
|
+
if (target.check !== 'roles' && !ensureBrowser()) return { target: target, verdict: 'could not confirm', why: 'the browser could not be downloaded', newProblems: [] };
|
|
2990
3028
|
const r = await runner.recheck(USER_DIR, flows, target, {
|
|
2991
3029
|
say: say,
|
|
2992
3030
|
onControl: (c) => control && control.onStop(() => c.stop()),
|
|
@@ -3706,7 +3744,9 @@ async function main() {
|
|
|
3706
3744
|
return finishWith(await recheckCommand(rest.find((a) => !/^--/.test(a)), { yes: rest.includes('--yes') }));
|
|
3707
3745
|
case 'edge':
|
|
3708
3746
|
case 'reliability':
|
|
3709
|
-
|
|
3747
|
+
case 'roles':
|
|
3748
|
+
case 'authz':
|
|
3749
|
+
return finishWith(await probeCommand(command === 'authz' ? 'roles' : command, rest));
|
|
3710
3750
|
case 'payments':
|
|
3711
3751
|
return finishWith(await paymentsCommand(rest));
|
|
3712
3752
|
case '-v':
|
package/kryptheon-authz.js
CHANGED
|
@@ -815,6 +815,14 @@ module.exports = {
|
|
|
815
815
|
judgeWrite: judgeWrite,
|
|
816
816
|
runAuthz: runAuthz,
|
|
817
817
|
reportLines: reportLines,
|
|
818
|
+
// Used by kryptheon-roles.js, which tries the same thing for any app.
|
|
819
|
+
makeContext: makeContext,
|
|
820
|
+
makeSession: makeSession,
|
|
821
|
+
stringsOf: stringsOf,
|
|
822
|
+
identifierLike: identifierLike,
|
|
823
|
+
foundIn: foundIn,
|
|
824
|
+
clip: clip,
|
|
825
|
+
getPath: getPath,
|
|
818
826
|
};
|
|
819
827
|
|
|
820
828
|
// --- command line -----------------------------------------------------------
|
|
@@ -302,8 +302,8 @@
|
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
var CHECK_NAME = { regression: 'Recorded flows', frontend: 'Frontend code', data: 'Database', edge: 'Input and edge cases', reliability: 'Reliability', payments: 'Payments' };
|
|
306
|
-
var CHECK_TONE = { regression: 'sun', frontend: 'amber', data: 'dusk', edge: 'ember', reliability: 'ember', payments: 'ember' };
|
|
305
|
+
var CHECK_NAME = { regression: 'Recorded flows', frontend: 'Frontend code', data: 'Database', edge: 'Input and edge cases', reliability: 'Reliability', payments: 'Payments', roles: 'Roles and tenants' };
|
|
306
|
+
var CHECK_TONE = { regression: 'sun', frontend: 'amber', data: 'dusk', edge: 'ember', reliability: 'ember', payments: 'ember', roles: 'ember' };
|
|
307
307
|
|
|
308
308
|
function counts() {
|
|
309
309
|
var confirmed = state.findings.filter(function (f) { return f.status === 'confirmed'; }).length;
|
|
@@ -877,7 +877,7 @@
|
|
|
877
877
|
var askingProbe = el('div', 'controls f-quick');
|
|
878
878
|
askingProbe.appendChild(probeConsentBox(probeAsking.check, 'Yes, try it again', function (body) {
|
|
879
879
|
runJob('/api/recheck', Object.assign({ id: f.id }, body)).then(function (done) { heard(f, (done && done.result) || {}); }, function () {});
|
|
880
|
-
}, RECHECK_WORDS[f.check === 'reliability' ? f.kind : 'edge']));
|
|
880
|
+
}, RECHECK_WORDS[f.check === 'reliability' ? f.kind : f.check === 'roles' ? 'roles' : 'edge']));
|
|
881
881
|
card.appendChild(askingProbe);
|
|
882
882
|
} else if (pending && pending.step === 'finding' && pending.finding && pending.finding.id === f.id) {
|
|
883
883
|
var asking = el('div', 'controls f-quick');
|
|
@@ -955,7 +955,7 @@
|
|
|
955
955
|
}
|
|
956
956
|
|
|
957
957
|
var STATE_TONE = { 'problems found': 'ember', 'things to check': 'amber', 'last run held': 'leaf', 'nothing found': 'leaf', 'stopped part way': 'amber', 'nothing was tested': 'amber' };
|
|
958
|
-
var PROBE_LABEL = { edge: 'Try inputs - adds test data', reliability: 'Replay 3x - adds test data' };
|
|
958
|
+
var PROBE_LABEL = { edge: 'Try inputs - adds test data', reliability: 'Replay 3x - adds test data', roles: 'Roles and tenants - changes data' };
|
|
959
959
|
// What one re-check press does, said before the yes.
|
|
960
960
|
var RECHECK_WORDS = {
|
|
961
961
|
edge: 'Re-check: replays this flow as recorded, then once more with the value that found this. Two runs.',
|
|
@@ -963,6 +963,7 @@
|
|
|
963
963
|
double: 'Re-check: replays this flow once, then once more with this step double-clicked. Two runs.',
|
|
964
964
|
phone: 'Re-check: replays this flow once, then once more at phone size, clicking every button with saving blocked. Two runs.',
|
|
965
965
|
race: 'Re-check: replays this flow once, then once more with this save sent twice at the same moment. Two runs.',
|
|
966
|
+
roles: 'Re-check: tries this one action again as every account, from the requests the last press learned. If a check is still missing it changes data in your app; it puts back what it can.',
|
|
966
967
|
shown: 'Re-check: replays this flow three times, looking for what this step saved on the page right after it. It is fixed only if it shows right away.',
|
|
967
968
|
};
|
|
968
969
|
|
|
@@ -973,7 +974,7 @@
|
|
|
973
974
|
var check = state.checks.filter(function (c) { return c.id === id; })[0];
|
|
974
975
|
var asks = check && check.asks;
|
|
975
976
|
var box = el('div', 'consent');
|
|
976
|
-
box.appendChild(el('div', 'd-step', 'THIS ADDS TEST DATA TO YOUR APP'));
|
|
977
|
+
box.appendChild(el('div', 'd-step', id === 'roles' ? 'THIS CHANGES DATA IN YOUR APP' : 'THIS ADDS TEST DATA TO YOUR APP'));
|
|
977
978
|
// The first line says what this press does; the rest - where, and what
|
|
978
979
|
// it leaves behind - is the same for the check and for a re-check.
|
|
979
980
|
var lines = ((asks && asks.lines) || []).slice();
|
|
@@ -1106,7 +1107,12 @@
|
|
|
1106
1107
|
card.appendChild(withCommand(pay, 'npx kryptheon payments'));
|
|
1107
1108
|
}
|
|
1108
1109
|
} else if (c.asks && c.enabled) {
|
|
1109
|
-
if (
|
|
1110
|
+
if (c.policy && !c.policy.ok) {
|
|
1111
|
+
// The roles check does not guess who may do what: it needs the app's own file first.
|
|
1112
|
+
card.appendChild(linesBox('warn', c.policy.lines));
|
|
1113
|
+
} else if (c.asks.localOnly && c.asks.live.length) {
|
|
1114
|
+
card.appendChild(linesBox('warn', ['Your recordings open ' + c.asks.live.join(', ') + ', which is not this computer.', 'This check sends requests that must be refused, so it runs only against your app on this computer (localhost or 127.0.0.1).']));
|
|
1115
|
+
} else if (probeAsking && probeAsking.check === c.id && !probeAsking.finding) {
|
|
1110
1116
|
card.appendChild(probeConsentBox(c.id, 'Yes, add test data and run', function (body) {
|
|
1111
1117
|
runJob('/api/probe', Object.assign({ id: c.id }, body)).then(function (done) {
|
|
1112
1118
|
var r = (done && done.result) || {};
|
|
@@ -1206,7 +1212,7 @@
|
|
|
1206
1212
|
if (f.check === 'data') { prepare('recheck', 'finding', f); return; }
|
|
1207
1213
|
// An input finding is re-checked by typing its value again, which adds
|
|
1208
1214
|
// test data to the app: the same yes as the check's own button, first.
|
|
1209
|
-
if (f.check === 'edge' || f.check === 'reliability') { probeAsking = { check: f.check, finding: f }; openRow = null; renderFindings(); return; }
|
|
1215
|
+
if (f.check === 'edge' || f.check === 'reliability' || f.check === 'roles') { probeAsking = { check: f.check, finding: f }; openRow = null; renderFindings(); return; }
|
|
1210
1216
|
// A payment finding needs a new payment: the same yes, and one more test payment.
|
|
1211
1217
|
if (f.check === 'payments') { paymentsAsking = { finding: f }; openRow = null; renderFindings(); return; }
|
|
1212
1218
|
runJob('/api/recheck', { id: f.id }).then(function (done) { heard(f, (done && done.result) || {}); }, function () {});
|
package/kryptheon-dashboard.js
CHANGED
|
@@ -52,6 +52,8 @@ const CHECKS = [
|
|
|
52
52
|
what: 'Replays your recorded forms with one field at a time given an unusual value - empty, 5000 characters, an HTML tag, emoji, a negative number, a number just past the lowest or highest the page allows, a date that does not exist - and reports only what it can prove: a page error, a 5xx, a bad value saved, a tag shown as HTML. It adds test data to your app, so it runs only when you press its button.' },
|
|
53
53
|
{ id: 'reliability', label: 'Reliability', available: true, asks: true,
|
|
54
54
|
what: 'Replays each recorded flow and reports one that sometimes works and sometimes fails, with the failed run as proof; and clicks each step that saves twice, quickly, reporting when that saves twice, with both answers as proof; on an app on this computer, sends each save twice at the same moment, reporting a server that makes two records or fails; and looks for what each save added on the page right after it, reporting a page that shows it only when opened again; after an edit, opens the form again and reports a field that kept its old value; and at phone size clicks every button with saving blocked, reporting a click - or a page as it loads - that throws an error. It adds test data to your app, so it runs only when you press its button.' },
|
|
55
|
+
{ id: 'roles', label: 'Roles and tenants', available: true, asks: true,
|
|
56
|
+
what: 'Signs in as each account your recordings use and tries every recorded action as every one of them, against the permissions-policy.json in your app folder: a role that may not do it must be refused, one that may must still work, and one organization must not reach another organization records. Judged from what comes back and what your app stored before and after. It runs only against an app on this computer.' },
|
|
55
57
|
{ id: 'payments', label: 'Payments: a webhook sent twice', available: true,
|
|
56
58
|
what: 'Real payments in Razorpay\'s or Stripe\'s TEST mode, through a proxy on this computer, each checked as it comes until you press Stop. Its signed webhook is sent to your app again, then once with a wrong signature, and your database is read before and after each - reporting the plan, credits or order given a second time, a repeat answered with an error, or a forged webhook accepted. Live mode is never sent again. It runs only when you press its button.' },
|
|
57
59
|
{ id: 'api', label: 'API', available: false },
|
|
@@ -66,7 +68,7 @@ const CHECK_IDS = new Set(CHECKS.map((c) => c.id));
|
|
|
66
68
|
// here (rounds 19 and 20: roles, payment rules, counts and searches).
|
|
67
69
|
const NOT_CHECKED = [
|
|
68
70
|
{ what: 'Who can do what',
|
|
69
|
-
why: 'Whether a lower role - a member, a customer - can open, change or delete what only a higher role should, or reach another account\'s record by changing an id in the address. Kryptheon replays each recording as the person who made it
|
|
71
|
+
why: 'Whether a lower role - a member, a customer - can open, change or delete what only a higher role should, or reach another account\'s record by changing an id in the address. Kryptheon replays each recording as the person who made it. The Roles and tenants check does try one account\'s actions as another, but only against the permissions-policy.json you write; without that file, or for anything it was not told, this is still not checked.',
|
|
70
72
|
yourself: 'Sign in as each role and open the higher role\'s pages and actions directly, by their address.' },
|
|
71
73
|
{ what: 'Payment rules beyond a repeat',
|
|
72
74
|
why: 'Only the same webhook sent again, and a copy with a wrong signature, are tried. Not tried: a webhook with no signature at all, an amount or currency that does not match the order, buying again while a plan is active, or when a refund takes access away.',
|
|
@@ -258,17 +260,20 @@ function probeAsk(root, what, env, options) {
|
|
|
258
260
|
}
|
|
259
261
|
// The pages, and where the app was last seen saving (kryptheon-probe.js).
|
|
260
262
|
const addresses = probe.knownAddresses(root, sources, env);
|
|
261
|
-
return { addresses: addresses, live: probe.liveLooking(addresses), lines: probe.consentLines(what, addresses, options) };
|
|
263
|
+
return { addresses: addresses, live: probe.liveLooking(addresses), lines: probe.consentLines(what, addresses, options), localOnly: Boolean(options && options.localOnly) };
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
const PROBE_WHAT = {
|
|
267
|
+
get roles() { return rolesModule().WHAT; },
|
|
265
268
|
edge: 'Input and edge cases: replays your recorded forms with one field at a time given an unusual value (empty, 5000 characters, an HTML tag, emoji, a negative number, a number just past the lowest or highest the page allows, a date that does not exist). At most 40 runs.',
|
|
266
269
|
reliability: 'Reliability: replays each recorded flow three times, clicks each step that saves (Save, Add, Create...) twice, quickly, sends each save twice at the same moment (only to an app on this computer), looks for what each save added on the page right after it, and at phone size clicks every button with saving blocked. At most 40 runs.',
|
|
267
270
|
};
|
|
268
271
|
// The reliability check types nothing of its own, so nothing it saves can
|
|
269
272
|
// carry the kryptheon-test marker - and its words do not promise one.
|
|
270
|
-
const PROBE_WORDS = { reliability: { marker: false } };
|
|
271
|
-
const PROBE_CHECKS = ['edge', 'reliability'];
|
|
273
|
+
const PROBE_WORDS = { reliability: { marker: false }, get roles() { return Object.assign({ localOnly: true }, rolesModule().WORDS); } };
|
|
274
|
+
const PROBE_CHECKS = ['edge', 'reliability', 'roles'];
|
|
275
|
+
// The roles check is loaded when it is first needed.
|
|
276
|
+
const rolesModule = () => require('./kryptheon-roles.js');
|
|
272
277
|
|
|
273
278
|
// Loaded when it is first needed, so a page that never shows payments never
|
|
274
279
|
// reads it (and pg is only ever loaded by a run).
|
|
@@ -757,7 +762,9 @@ function buildState(root, env) {
|
|
|
757
762
|
// data: --yes says yes for an app on this computer, and is refused for
|
|
758
763
|
// any other address - there the person must answer.
|
|
759
764
|
f.fixPrompt += '\n\nWhen you have fixed it, prove it: run npx kryptheon recheck ' + f.id + ' --yes' +
|
|
760
|
-
|
|
765
|
+
(f.check === 'roles'
|
|
766
|
+
? ' (it tries this action again as every account, which changes data if a check is still missing; --yes works only for an app running on this computer). '
|
|
767
|
+
: ' (it runs the flow in the app again, adding a little test data; --yes works only for an app running on this computer). ') +
|
|
761
768
|
'It is fixed only when that says FIXED.';
|
|
762
769
|
} else if (f.fixPrompt) {
|
|
763
770
|
f.fixPrompt += '\n\nWhen you have fixed it, prove it: run npx kryptheon recheck ' + f.id +
|
|
@@ -802,6 +809,8 @@ function buildState(root, env) {
|
|
|
802
809
|
// A check that adds data to the app: never in "Run all", never on its
|
|
803
810
|
// own - only its own button, after the page has shown these words.
|
|
804
811
|
asks: c.asks && config.enabled[c.id] && recordings > 0 ? probeAsk(root, PROBE_WHAT[c.id], env, PROBE_WORDS[c.id]) : null,
|
|
812
|
+
// The roles check needs the app's own permissions file first; the page says so instead of asking.
|
|
813
|
+
policy: c.id === 'roles' && config.enabled.roles ? rolesModule().preflight(root) : null,
|
|
805
814
|
// What the payment check says before its yes, and the app it starts
|
|
806
815
|
// from: the saved address when it is this computer's, else the usual one.
|
|
807
816
|
payments: c.id === 'payments' && config.enabled.payments ? paymentsAsk(readAppAddress(paths), paymentsLast) : null,
|
|
@@ -884,8 +893,9 @@ function buildState(root, env) {
|
|
|
884
893
|
// What each run is called on the page, and the command that does the same in
|
|
885
894
|
// a terminal - shown under every button, for when the page cannot be used.
|
|
886
895
|
const RUN_TITLE = { frontend: 'Reading your code', regression: 'Replaying your recordings', edge: 'Trying unusual inputs in your forms', reliability: 'Replaying your flows three times, and double-clicking',
|
|
896
|
+
roles: 'Trying every recorded action as each account',
|
|
887
897
|
payments: 'Waiting for test payments, and sending each webhook again' };
|
|
888
|
-
const RUN_COMMAND = { frontend: 'npx kryptheon code', regression: 'npx kryptheon check', edge: 'npx kryptheon edge', reliability: 'npx kryptheon reliability',
|
|
898
|
+
const RUN_COMMAND = { frontend: 'npx kryptheon code', regression: 'npx kryptheon check', edge: 'npx kryptheon edge', reliability: 'npx kryptheon reliability', roles: 'npx kryptheon roles',
|
|
889
899
|
payments: 'npx kryptheon payments' };
|
|
890
900
|
const DB_ACTIONS = {
|
|
891
901
|
scan: { title: 'Checking your database', command: 'npx kryptheon-night' },
|
|
@@ -1206,6 +1216,10 @@ function createServer(root, options) {
|
|
|
1206
1216
|
const check = buildState(root, env).checks.find((c) => c.id === id);
|
|
1207
1217
|
if (!check || !check.asks) return (check ? check.label : '"' + id + '"') + ' cannot be run from here';
|
|
1208
1218
|
if (input.consent !== true) return 'it adds test data to your app, so it runs only after you say yes';
|
|
1219
|
+
if (id === 'roles') {
|
|
1220
|
+
if (check.policy && !check.policy.ok) return check.policy.lines[0];
|
|
1221
|
+
if (check.asks.live.length) return 'it sends requests that must be refused, so it runs only against your app on this computer - ' + check.asks.live.join(', ') + ' is not';
|
|
1222
|
+
}
|
|
1209
1223
|
if (check.asks.live.length && input.liveConfirmed !== true) {
|
|
1210
1224
|
return check.asks.live.join(', ') + ' is not this computer - tick that it is your own test copy first';
|
|
1211
1225
|
}
|
package/kryptheon-heal.js
CHANGED
|
@@ -45,6 +45,16 @@ const ACTIONS = [
|
|
|
45
45
|
const ACTION_ROLES = new Set(['button', 'link']);
|
|
46
46
|
const FIELD_ROLES = new Set(['textbox', 'searchbox', 'combobox', 'listbox', 'spinbutton', 'checkbox', 'radio', 'slider', 'switch']);
|
|
47
47
|
|
|
48
|
+
// A click on a table cell whose words hold a number - an id, a tracking
|
|
49
|
+
// number, a date, an amount - is the recorder catching a look at the data,
|
|
50
|
+
// and the data moves. Found on blind round 23: the recording clicked the cell
|
|
51
|
+
// "#PP-34 PP-M52AGIAV" (the shipment it made, by its tracking number); later
|
|
52
|
+
// runs added shipments, that row left the list, every replay stopped there,
|
|
53
|
+
// and none of the saves after it was ever checked. Such a click, its cell
|
|
54
|
+
// gone, is skipped and said - never quietly passed.
|
|
55
|
+
const LOOK_ROLES = new Set(['cell', 'gridcell']);
|
|
56
|
+
const lookClick = (role, name, method) => method === 'click' && LOOK_ROLES.has(role) && /\d/.test(String(name || ''));
|
|
57
|
+
|
|
48
58
|
function norm(text) {
|
|
49
59
|
return String(text == null ? '' : text).replace(/\s+/g, ' ').trim().toLowerCase();
|
|
50
60
|
}
|
|
@@ -199,6 +209,10 @@ function watch(page, options) {
|
|
|
199
209
|
return replacement[method].apply(replacement, args);
|
|
200
210
|
}
|
|
201
211
|
}
|
|
212
|
+
if (lookClick(role, name, method)) {
|
|
213
|
+
renamed.push({ role: role, was: name, skipped: true });
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
202
216
|
// Not a rename this can prove: the step fails the way it always did.
|
|
203
217
|
return real.apply(locator, args);
|
|
204
218
|
}
|
|
@@ -291,6 +305,10 @@ function countPattern(text) {
|
|
|
291
305
|
|
|
292
306
|
/** The report line, shared by the terminal and the history. */
|
|
293
307
|
function describeRename(entry) {
|
|
308
|
+
if (entry.skipped) {
|
|
309
|
+
return 'The ' + entry.role + ' "' + entry.was + '" was not on the page - it holds an id, date or number that moves with the data, ' +
|
|
310
|
+
'so I skipped clicking it and carried on. If that click mattered, record that step again on something that does not change.';
|
|
311
|
+
}
|
|
294
312
|
if (entry.role === 'text' && entry.counted) {
|
|
295
313
|
return 'The text "' + entry.was + '" now reads "' + entry.now + '" - only its number changed, so I clicked it and carried on.';
|
|
296
314
|
}
|
|
@@ -98,7 +98,10 @@ function tunnelLines(port, stopWith) {
|
|
|
98
98
|
];
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
// Said as the one who sends (Razorpay sends ...); ADJ before a noun (a Razorpay webhook).
|
|
102
|
+
// 'signed' is an app's own signed webhook, named with --signature-header.
|
|
103
|
+
const PROVIDER = { razorpay: 'Razorpay', stripe: 'Stripe', signed: 'your provider' };
|
|
104
|
+
const ADJ = (p) => (p === 'signed' ? 'signed' : PROVIDER[p]);
|
|
102
105
|
|
|
103
106
|
/** The prompt pasted into an AI tool for one finding. */
|
|
104
107
|
function fixPrompt(result, f) {
|
|
@@ -108,7 +111,7 @@ function fixPrompt(result, f) {
|
|
|
108
111
|
return [
|
|
109
112
|
'My app gives a payment twice when ' + who + ' sends the same webhook again.',
|
|
110
113
|
'',
|
|
111
|
-
'I tested it with a real ' +
|
|
114
|
+
'I tested it with a real ' + ADJ(result.provider) + ' test payment: the ' + result.event.type + ' webhook was sent to ' + where +
|
|
112
115
|
' a second time, byte for byte, and my database changed again:',
|
|
113
116
|
].concat(f.changes.map((c) => ' ' + c), [
|
|
114
117
|
'',
|
|
@@ -129,7 +132,7 @@ function fixPrompt(result, f) {
|
|
|
129
132
|
return [
|
|
130
133
|
'When ' + who + ' tells my app a payment was refunded, my app changes nothing.',
|
|
131
134
|
'',
|
|
132
|
-
'I tested it with a real ' +
|
|
135
|
+
'I tested it with a real ' + ADJ(result.provider) + ' test refund: the ' + result.event.type + ' webhook reached ' + where +
|
|
133
136
|
', which answered ' + f.status + (f.said ? ' (' + f.said.slice(0, 120) + ')' : '') + ' and wrote nothing but its log.',
|
|
134
137
|
'So the credits, plan or order that payment gave are still there after the money went back.',
|
|
135
138
|
'',
|
|
@@ -147,7 +150,7 @@ function fixPrompt(result, f) {
|
|
|
147
150
|
: f.kind === 'refund-twice' ? 'My app takes back what a payment gave twice for one refund: on refund.created and again on refund.processed.'
|
|
148
151
|
: 'A ' + result.event.type + ' webhook took a number in my database below zero.',
|
|
149
152
|
'',
|
|
150
|
-
'I tested it with ' +
|
|
153
|
+
'I tested it with ' + ADJ(result.provider) + ' test webhooks sent to ' + where + '. The first delivery of ' + result.event.type + ' changed:',
|
|
151
154
|
].concat(f.changes.map((c) => ' ' + c), [
|
|
152
155
|
'',
|
|
153
156
|
'Fix ' + where + ' so a refund is applied once, at the right step:',
|
|
@@ -162,7 +165,7 @@ function fixPrompt(result, f) {
|
|
|
162
165
|
return [
|
|
163
166
|
'My app answers ' + f.status + ' when ' + who + ' sends the same webhook again.',
|
|
164
167
|
'',
|
|
165
|
-
'I tested it with a real ' +
|
|
168
|
+
'I tested it with a real ' + ADJ(result.provider) + ' test payment: the second copy of ' + result.event.type + ' to ' + where +
|
|
166
169
|
' changed nothing in my database, but was answered ' + f.status + '.',
|
|
167
170
|
who + ' treats that as a failed delivery and keeps sending it' +
|
|
168
171
|
(result.provider === 'razorpay' ? ', and switches a webhook off after it keeps failing.' : '.'),
|
|
@@ -171,20 +174,37 @@ function fixPrompt(result, f) {
|
|
|
171
174
|
'Postgres 23505), treat it as done and answer 200. Change nothing else. Afterwards I will run: npx kryptheon payments',
|
|
172
175
|
].join('\n');
|
|
173
176
|
}
|
|
177
|
+
const header = result.provider === 'razorpay' ? 'X-Razorpay-Signature header' : result.provider === 'stripe' ? 'Stripe-Signature header'
|
|
178
|
+
: (result.signatureHeader || 'signature') + ' header';
|
|
179
|
+
const how = result.provider === 'razorpay' ? ' (HMAC-SHA256, hex - or Razorpay\'s validateWebhookSignature)'
|
|
180
|
+
: result.provider === 'stripe' ? ' (stripe.webhooks.constructEvent)' : ' (the HMAC your provider documents, usually SHA-256)';
|
|
181
|
+
if (f.kind === 'no-signature') {
|
|
182
|
+
return [
|
|
183
|
+
'My payment webhook accepts a request with no signature at all.',
|
|
184
|
+
'',
|
|
185
|
+
'I tested it: a copy of a real test webhook, with the ' + header + ' left out, was sent to ' + where + ' and answered ' + f.status + '.' +
|
|
186
|
+
(f.changes.length ? ' It also changed my database:' : ''),
|
|
187
|
+
].concat(f.changes.map((c) => ' ' + c), [
|
|
188
|
+
'',
|
|
189
|
+
'The same copy with a wrong signature was refused, so the check is there - but a missing signature skips it.',
|
|
190
|
+
'Anyone who can reach this address could send it a payment that never happened.',
|
|
191
|
+
'',
|
|
192
|
+
'Fix ' + where + ': a request with no ' + header + ' must be refused with 400, the same as a wrong one, before anything is saved.',
|
|
193
|
+
'Do not change anything else. Afterwards I will run: npx kryptheon payments',
|
|
194
|
+
]).join('\n');
|
|
195
|
+
}
|
|
174
196
|
return [
|
|
175
197
|
f.refused ? 'My payment webhook answers ' + f.status + ' to a request with a wrong signature, but still changes my database.'
|
|
176
198
|
: 'My payment webhook accepts a request with a wrong signature.',
|
|
177
199
|
'',
|
|
178
|
-
'I tested it: a copy of a real ' +
|
|
200
|
+
'I tested it: a copy of a real ' + ADJ(result.provider) + ' test webhook, with its signature changed by one character, was sent to ' +
|
|
179
201
|
where + ' and answered ' + f.status + '.' + (f.changes.length ? ' It also changed my database:' : ''),
|
|
180
202
|
].concat(f.changes.map((c) => ' ' + c), [
|
|
181
203
|
'',
|
|
182
204
|
'Anyone who can reach this address could send it a payment that never happened.',
|
|
183
205
|
'',
|
|
184
|
-
'Fix ' + where + ': before anything else, check the ' +
|
|
185
|
-
' against the RAW request body with the webhook secret' +
|
|
186
|
-
? ' (HMAC-SHA256, hex - or Razorpay\'s validateWebhookSignature)'
|
|
187
|
-
: ' (stripe.webhooks.constructEvent)') + ', compare it in constant time,',
|
|
206
|
+
'Fix ' + where + ': before anything else, check the ' + header +
|
|
207
|
+
' against the RAW request body with the webhook secret' + how + ', compare it in constant time,',
|
|
188
208
|
'and answer 400 without changing anything when it does not match. Afterwards I will run: npx kryptheon payments',
|
|
189
209
|
]).join('\n');
|
|
190
210
|
}
|
|
@@ -194,7 +214,7 @@ function findingLines(result, f) {
|
|
|
194
214
|
const who = PROVIDER[result.provider];
|
|
195
215
|
if (f.kind === 'repeat-grants') {
|
|
196
216
|
return [
|
|
197
|
-
'HIGH The same ' +
|
|
217
|
+
'HIGH The same ' + ADJ(result.provider) + ' webhook, sent again, gave it again.',
|
|
198
218
|
'',
|
|
199
219
|
' ' + result.event.type + ' to ' + result.path + ' was sent a second time, byte for byte, as ' + who + ' does on a retry.',
|
|
200
220
|
' Your database changed again:',
|
|
@@ -239,6 +259,13 @@ function findingLines(result, f) {
|
|
|
239
259
|
(result.provider === 'razorpay' ? ' and switches a webhook off after repeated failures.' : '.'),
|
|
240
260
|
];
|
|
241
261
|
}
|
|
262
|
+
if (f.kind === 'no-signature') {
|
|
263
|
+
return [
|
|
264
|
+
(f.severity === 'CRITICAL' ? 'CRITICAL ' : 'MEDIUM ') + 'Your webhook took a copy with no signature at all (answered ' + f.status + ').',
|
|
265
|
+
'',
|
|
266
|
+
' A wrong signature was refused, so the check exists - but leaving the signature out skips it.',
|
|
267
|
+
].concat(f.changes.length ? [' And it gave it again:'].concat(f.changes.map((c) => ' ' + c)) : [' It did not change your database, but it should refuse it with 400.']);
|
|
268
|
+
}
|
|
242
269
|
return [
|
|
243
270
|
(f.severity === 'CRITICAL' ? 'CRITICAL ' : 'MEDIUM ') + (f.refused
|
|
244
271
|
? 'Your webhook refused a copy with a wrong signature (answered ' + f.status + '), but still changed your data.'
|
|
@@ -254,7 +281,7 @@ function reportLines(report) {
|
|
|
254
281
|
const out = [];
|
|
255
282
|
for (const r of report.results) {
|
|
256
283
|
out.push('--------------------------------------------------------------------');
|
|
257
|
-
out.push(
|
|
284
|
+
out.push(ADJ(r.provider) + ' ' + r.event.type + (r.event.about ? ' (' + r.event.about + ')' : '') + ' -> ' + r.path);
|
|
258
285
|
out.push('');
|
|
259
286
|
if (r.notTested.length) {
|
|
260
287
|
for (const n of r.notTested) out.push('NOT TESTED ' + n);
|
|
@@ -368,7 +395,7 @@ async function run(root, options) {
|
|
|
368
395
|
};
|
|
369
396
|
let capture;
|
|
370
397
|
try {
|
|
371
|
-
capture = await payments.startCapture({ target: app, port: port, beforeForward: readBefore });
|
|
398
|
+
capture = await payments.startCapture({ target: app, port: port, beforeForward: readBefore, signatureHeader: options.signatureHeader });
|
|
372
399
|
} catch (err) {
|
|
373
400
|
await client.end().catch(() => {});
|
|
374
401
|
say('Could not start the proxy on port ' + port + ': ' + err.message + '. Try --port <another number>.');
|
|
@@ -403,7 +430,7 @@ async function run(root, options) {
|
|
|
403
430
|
if (!arrived) break;
|
|
404
431
|
const lead = capture.captured[next];
|
|
405
432
|
say('');
|
|
406
|
-
say('A ' +
|
|
433
|
+
say('A ' + ADJ(lead.provider) + ' webhook arrived (' + payments.eventOf(lead).type + '). Waiting a few seconds for the rest of this payment ...');
|
|
407
434
|
await new Promise((r) => setTimeout(r, options.gatherMs !== undefined ? options.gatherMs : GATHER_MS));
|
|
408
435
|
|
|
409
436
|
const hooks = capture.captured.slice(next);
|
|
@@ -499,7 +526,7 @@ function save(root, report) {
|
|
|
499
526
|
}
|
|
500
527
|
}
|
|
501
528
|
|
|
502
|
-
const STEP_NAME = { first: 'the payment\'s own webhook', repeat: 'the same webhook again', 'wrong-signature': 'a copy with a wrong signature' };
|
|
529
|
+
const STEP_NAME = { first: 'the payment\'s own webhook', repeat: 'the same webhook again', 'wrong-signature': 'a copy with a wrong signature', 'no-signature': 'a copy with no signature' };
|
|
503
530
|
|
|
504
531
|
/** One result's trace, as lines: each delivery, when, its answer, and what it wrote. */
|
|
505
532
|
function traceLines(r) {
|
package/kryptheon-payments.js
CHANGED
|
@@ -62,14 +62,25 @@ function isLocalAddress(url) {
|
|
|
62
62
|
host.endsWith('.local') || host.endsWith('.localhost') || host.endsWith('.test');
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/**
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Which provider signed this request, from its headers, or null. An app's
|
|
67
|
+
* own signed webhook - its own header, named by the person with
|
|
68
|
+
* --signature-header - is 'signed'. Found on blind round 23: the app signed
|
|
69
|
+
* its payment webhooks in x-test-signature, and nothing was tested.
|
|
70
|
+
*/
|
|
71
|
+
function providerOf(headers, signatureHeader) {
|
|
67
72
|
const h = headers || {};
|
|
68
73
|
if (h['x-razorpay-signature']) return 'razorpay';
|
|
69
74
|
if (h['stripe-signature']) return 'stripe';
|
|
75
|
+
if (signatureHeader && h[String(signatureHeader).toLowerCase()]) return 'signed';
|
|
70
76
|
return null;
|
|
71
77
|
}
|
|
72
78
|
|
|
79
|
+
/** The header a hook's signature is in. */
|
|
80
|
+
function signatureHeaderOf(hook) {
|
|
81
|
+
return hook.signatureHeader || SIGNATURE_HEADER[hook.provider];
|
|
82
|
+
}
|
|
83
|
+
|
|
73
84
|
function parsed(body) {
|
|
74
85
|
try {
|
|
75
86
|
return JSON.parse(Buffer.isBuffer(body) ? body.toString('utf8') : String(body));
|
|
@@ -96,6 +107,7 @@ function modeOf(provider, body, env) {
|
|
|
96
107
|
if (keys.some((v) => /^rzp_test_/.test(v))) return { mode: 'test', why: 'your app has a test Razorpay key (rzp_test_)' };
|
|
97
108
|
return { mode: null, why: 'no Razorpay key id (rzp_test_ or rzp_live_) was found in your app\'s .env files' };
|
|
98
109
|
}
|
|
110
|
+
if (provider === 'signed') return { mode: null, why: 'an app\'s own signed webhook does not say whether it is live' };
|
|
99
111
|
return { mode: null, why: 'not a payment webhook' };
|
|
100
112
|
}
|
|
101
113
|
|
|
@@ -114,13 +126,18 @@ function eventOf(hook) {
|
|
|
114
126
|
const object = json.data && json.data.object;
|
|
115
127
|
return { type: json.type || 'a Stripe event', id: json.id || null, about: object && object.id ? object.id : null };
|
|
116
128
|
}
|
|
129
|
+
if (hook.provider === 'signed') {
|
|
130
|
+
const pick = (...keys) => { for (const k of keys) if (json[k] !== undefined && json[k] !== null && typeof json[k] !== 'object') return String(json[k]); return null; };
|
|
131
|
+
return { type: pick('event', 'type', 'eventType', 'event_type') || 'a signed event', id: pick('eventId', 'event_id', 'id'), about: pick('paymentId', 'payment_id', 'refundId', 'refund_id') };
|
|
132
|
+
}
|
|
117
133
|
return { type: 'a request', id: null, about: null };
|
|
118
134
|
}
|
|
119
135
|
|
|
120
136
|
/** The headers a copy is sent with, taken from what arrived. */
|
|
121
|
-
function keptHeaders(headers) {
|
|
137
|
+
function keptHeaders(headers, signatureHeader) {
|
|
122
138
|
const out = {};
|
|
123
|
-
|
|
139
|
+
const names = signatureHeader ? KEPT_HEADERS.concat([String(signatureHeader).toLowerCase()]) : KEPT_HEADERS;
|
|
140
|
+
for (const name of names) if (headers[name] !== undefined) out[name] = headers[name];
|
|
124
141
|
return out;
|
|
125
142
|
}
|
|
126
143
|
|
|
@@ -142,7 +159,7 @@ function startCapture(options) {
|
|
|
142
159
|
req.on('end', async () => {
|
|
143
160
|
const body = Buffer.concat(chunks);
|
|
144
161
|
const receivedAt = new Date().toISOString();
|
|
145
|
-
const signed = providerOf(req.headers) && req.method === 'POST';
|
|
162
|
+
const signed = providerOf(req.headers, options.signatureHeader) && req.method === 'POST';
|
|
146
163
|
// The caller may read the database once before the first payment
|
|
147
164
|
// webhook reaches the app, so that delivery's own writes can be shown.
|
|
148
165
|
// Capped: the provider is waiting, and Razorpay gives up after 5 s.
|
|
@@ -172,10 +189,11 @@ function startCapture(options) {
|
|
|
172
189
|
res.end(said);
|
|
173
190
|
if (signed) {
|
|
174
191
|
const hook = {
|
|
175
|
-
provider: providerOf(req.headers),
|
|
192
|
+
provider: providerOf(req.headers, options.signatureHeader),
|
|
193
|
+
signatureHeader: providerOf(req.headers, options.signatureHeader) === 'signed' ? String(options.signatureHeader).toLowerCase() : undefined,
|
|
176
194
|
method: req.method,
|
|
177
195
|
path: req.url,
|
|
178
|
-
headers: keptHeaders(req.headers),
|
|
196
|
+
headers: keptHeaders(req.headers, options.signatureHeader),
|
|
179
197
|
body: body,
|
|
180
198
|
status: answer.statusCode,
|
|
181
199
|
at: Date.now(),
|
|
@@ -220,16 +238,18 @@ function spoiled(provider, value) {
|
|
|
220
238
|
|
|
221
239
|
/**
|
|
222
240
|
* Sends a kept webhook to the app again, byte for byte. With `badSignature`,
|
|
223
|
-
* the same bytes under a signature that does not match them
|
|
241
|
+
* the same bytes under a signature that does not match them; with
|
|
242
|
+
* `noSignature`, the same bytes with no signature header at all.
|
|
224
243
|
*/
|
|
225
244
|
function send(target, hook, options) {
|
|
226
245
|
const url = new URL(target);
|
|
227
246
|
if (!isLocalAddress(url.href)) return Promise.reject(new Error(url.origin + ' is not this computer'));
|
|
228
247
|
const headers = Object.assign({}, hook.headers, { 'content-length': Buffer.byteLength(hook.body), host: url.host });
|
|
229
248
|
if (options && options.badSignature) {
|
|
230
|
-
const name =
|
|
249
|
+
const name = signatureHeaderOf(hook);
|
|
231
250
|
headers[name] = spoiled(hook.provider, headers[name]);
|
|
232
251
|
}
|
|
252
|
+
if (options && options.noSignature) delete headers[signatureHeaderOf(hook)];
|
|
233
253
|
const sentAt = new Date().toISOString();
|
|
234
254
|
const began = Date.now();
|
|
235
255
|
const timed = (status, said) => ({ status: status, said: said, sentAt: sentAt, answeredAt: new Date().toISOString(), ms: Date.now() - began });
|
|
@@ -493,6 +513,7 @@ async function check(options) {
|
|
|
493
513
|
const say = options.say || (() => {});
|
|
494
514
|
const event = eventOf(hook);
|
|
495
515
|
const result = { provider: hook.provider, event: event, path: hook.path, firstStatus: hook.status, steps: [], findings: [], notTested: [] };
|
|
516
|
+
if (hook.signatureHeader) result.signatureHeader = hook.signatureHeader;
|
|
496
517
|
|
|
497
518
|
// The trace: every delivery of this webhook, when it went, what came back,
|
|
498
519
|
// and what it wrote. The body is never kept - its SHA-256 shows the repeat
|
|
@@ -592,8 +613,28 @@ async function check(options) {
|
|
|
592
613
|
changes: forgedBusiness.map(changeLine),
|
|
593
614
|
});
|
|
594
615
|
}
|
|
616
|
+
// 3. The same bytes with no signature at all. Found on blind round 23: a
|
|
617
|
+
// webhook that refused a wrong signature took a request that had none.
|
|
618
|
+
// Said only when the wrong one was refused: otherwise it is the same hole.
|
|
619
|
+
say('Sending a copy with no signature ...');
|
|
620
|
+
const bare = await send(target, hook, { noSignature: true });
|
|
621
|
+
const fourth = await settle(client, schema, tables, options);
|
|
622
|
+
const bareChanges = diff(third.snap, fourth.snap).map(judged);
|
|
623
|
+
const bareBusiness = bareChanges.filter((c) => c.class === 'business');
|
|
624
|
+
result.steps.push({ step: 'no-signature', status: bare.status, changes: bareChanges.map((c) => ({ class: c.class, line: changeLine(c) })) });
|
|
625
|
+
result.trace.deliveries.push(delivered('no-signature', bare, 'none', bareChanges, fourth.settled));
|
|
626
|
+
const forgedRefused = !ok(forged.status) && !forgedBusiness.length;
|
|
627
|
+
if (forgedRefused && (ok(bare.status) || bareBusiness.length)) {
|
|
628
|
+
result.findings.push({
|
|
629
|
+
kind: 'no-signature',
|
|
630
|
+
severity: bareBusiness.length ? 'CRITICAL' : 'MEDIUM',
|
|
631
|
+
status: bare.status,
|
|
632
|
+
refused: !ok(bare.status),
|
|
633
|
+
changes: bareBusiness.map(changeLine),
|
|
634
|
+
});
|
|
635
|
+
}
|
|
595
636
|
// What changed meanwhile but is not this webhook's, said so it is not lost.
|
|
596
|
-
const elsewhere = changes.concat(forgedChanges).filter((c) => c.class === 'elsewhere').map(changeLine);
|
|
637
|
+
const elsewhere = changes.concat(forgedChanges, bareChanges).filter((c) => c.class === 'elsewhere').map(changeLine);
|
|
597
638
|
if (elsewhere.length) result.elsewhere = elsewhere;
|
|
598
639
|
return result;
|
|
599
640
|
}
|
|
@@ -635,6 +676,7 @@ function lifecycle(result, earlier) {
|
|
|
635
676
|
}
|
|
636
677
|
|
|
637
678
|
module.exports = {
|
|
679
|
+
signatureHeaderOf: signatureHeaderOf,
|
|
638
680
|
lifecycle: lifecycle,
|
|
639
681
|
isLocalAddress: isLocalAddress,
|
|
640
682
|
providerOf: providerOf,
|