@noego/trust 0.5.1-dev.3 → 0.5.1-dev.4
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/dist/{baseline-DMNO7IAl.d.ts → baseline-DsqHPLAg.d.ts} +9 -2
- package/dist/{chunk-3IIEQHH2.js → chunk-35ETSKEC.js} +34 -2
- package/dist/chunk-35ETSKEC.js.map +1 -0
- package/dist/{chunk-VJGGEY4G.js → chunk-4XGOH7JE.js} +11 -1
- package/dist/{chunk-VJGGEY4G.js.map → chunk-4XGOH7JE.js.map} +1 -1
- package/dist/{chunk-2MSSO67W.js → chunk-6K5I3ZRI.js} +2 -2
- package/dist/cli/index.js +5 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/eslint/index.d.ts +3 -2
- package/dist/eslint/index.js +49 -14
- package/dist/eslint/index.js.map +1 -1
- package/dist/index.cjs +221 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -2
- package/dist/index.d.ts +47 -2
- package/dist/index.js +218 -2
- package/dist/index.js.map +1 -1
- package/dist/native/trust_native_wasm.wasm +0 -0
- package/package.json +4 -4
- package/dist/chunk-3IIEQHH2.js.map +0 -1
- /package/dist/{chunk-2MSSO67W.js.map → chunk-6K5I3ZRI.js.map} +0 -0
|
@@ -89,13 +89,14 @@ type ResultLookalikeSetting = 'off' | 'strict' | 'on';
|
|
|
89
89
|
/** Which callback parameters are untrusted-value sources (see the file comment). */
|
|
90
90
|
type UntrustedCallbacks = 'off' | 'inline' | 'all';
|
|
91
91
|
/** The rules that are off unless a config turns them on. */
|
|
92
|
-
type OptInRule = 'type-claim' | 'untrusted-value' | 'dropped-result' | 'trusted-state' | 'redundant-guard';
|
|
92
|
+
type OptInRule = 'type-claim' | 'untrusted-value' | 'dropped-result' | 'trusted-state' | 'redundant-guard' | 'finally-return';
|
|
93
93
|
interface TrustRuleSettings {
|
|
94
94
|
readonly 'type-claim': RuleSwitch;
|
|
95
95
|
readonly 'untrusted-value': RuleSwitch;
|
|
96
96
|
readonly 'dropped-result': RuleSwitch;
|
|
97
97
|
readonly 'trusted-state': RuleSwitch;
|
|
98
98
|
readonly 'redundant-guard': RuleSwitch;
|
|
99
|
+
readonly 'finally-return': RuleSwitch;
|
|
99
100
|
readonly 'result-lookalike': ResultLookalikeSetting;
|
|
100
101
|
readonly untrustedCallbacks: UntrustedCallbacks;
|
|
101
102
|
}
|
|
@@ -350,6 +351,12 @@ declare const REDUNDANT_GUARD_ORIGIN = "redundant";
|
|
|
350
351
|
declare const REDUNDANT_GUARD_MESSAGES: {
|
|
351
352
|
readonly redundant: "`{{guard}}` guards nothing that can fail: {{calls}}. It invents a failure path callers must unwrap for nothing. Call it directly and return its value; a trusted origin's failure is a programmer error, not a failure path. If the call can fail, remove its origin from \"trust\" in trust.config.json instead.";
|
|
352
353
|
};
|
|
354
|
+
declare const FINALLY_RETURN_RULE = "finally-return";
|
|
355
|
+
/** Origin label of every finally-return finding (baseline key). */
|
|
356
|
+
declare const FINALLY_RETURN_ORIGIN = "return";
|
|
357
|
+
declare const FINALLY_RETURN_MESSAGES: {
|
|
358
|
+
readonly return: "`return` inside `finally` overwrites any Result (Err or StatedOk) or throw leaving `try` / `catch`. Do not return from `finally`; use `Trust.using(acquire, use, release)` when cleanup returns a Result.";
|
|
359
|
+
};
|
|
353
360
|
declare const BOUNDARY_RULE = "boundary-result";
|
|
354
361
|
/**
|
|
355
362
|
* The messages of `boundary-result` (core/boundaries.ts), keyed by origin: the baseline key, and the ESLint
|
|
@@ -435,4 +442,4 @@ declare function describeBaselineDelta(delta: BaselineDelta<BaselineFinding & {
|
|
|
435
442
|
readonly message: string;
|
|
436
443
|
}>): string[];
|
|
437
444
|
|
|
438
|
-
export {
|
|
445
|
+
export { type OptInRule as $, updateBaseline as A, type BaselineCounts as B, type TrustRuleSettings as C, type TrustConfig as D, type OriginInfo as E, type Finding as F, type CatchProblem as G, ACCEPT_DIRECTIVE as H, ACCEPT_DIRECTIVE_MESSAGES as I, BOUNDARY_MESSAGES as J, BOUNDARY_RULE as K, type BoundaryGroup as L, type BoundaryOrigin as M, CATCH_ORIGIN as N, OriginResolver as O, DEFAULT_RULE_SETTINGS as P, DIRECTIVE_ORIGIN as Q, DROPPED_RESULT_MESSAGES as R, DROPPED_RESULT_RULE as S, type TypeScript as T, type DroppedResultOrigin as U, FINALLY_RETURN_MESSAGES as V, WHOLE_BASELINE as W, FINALLY_RETURN_ORIGIN as X, FINALLY_RETURN_RULE as Y, type ZoneGroup as Z, type LoadTrustConfigOptions as _, type TsconfigMapping as a, REDUNDANT_GUARD_MESSAGES as a0, REDUNDANT_GUARD_ORIGIN as a1, REDUNDANT_GUARD_RULE as a2, type RuleSwitch as a3, THROW_MESSAGES as a4, THROW_RULE as a5, TRUSTED_STATE_MESSAGES as a6, TRUSTED_STATE_RULE as a7, TYPE_CLAIM_KINDS as a8, TYPE_CLAIM_MESSAGES as a9, TYPE_CLAIM_RULE as aa, TrustConfigError as ab, type TrustEntry as ac, type TrustLevel as ad, type TrustedStateOrigin as ae, type TypeClaimOrigin as af, UNANALYZABLE_ORIGIN as ag, UNTRUSTED_CALL_MESSAGES as ah, UNTRUSTED_CALL_RULE as ai, UNTRUSTED_VALUE_MESSAGES as aj, UNTRUSTED_VALUE_RULE as ak, type UntrustedCallbacks as al, type UntrustedEntry as am, VALIDATOR_DIRECTIVE as an, effectiveTrustList as ao, effectiveTypeTrustList as ap, isInsideValidator as aq, isMarkedValidator as ar, isRuleEnabled as as, loadTrustConfig as at, normalizeOrigin as au, type BaselineDelta as b, type BaselineFinding as c, type BaselineScope as d, type TrustDirective as e, type Zone as f, Zones as g, compareToBaseline as h, countFindings as i, describeBaselineDelta as j, directiveDirectlyAbove as k, directiveReason as l, groupMatches as m, isNamedDirective as n, lineDirectivesIn as o, loadTypeScript as p, matchesPatterns as q, nearestPackageName as r, nodeBelow as s, normalizePattern as t, parseBaseline as u, readBaseline as v, realpathOrSelf as w, relativeInside as x, serializeBaseline as y, toPosix as z };
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
DIRECTIVE_ORIGIN,
|
|
9
9
|
DROPPED_RESULT_MESSAGES,
|
|
10
10
|
DROPPED_RESULT_RULE,
|
|
11
|
+
FINALLY_RETURN_MESSAGES,
|
|
12
|
+
FINALLY_RETURN_ORIGIN,
|
|
13
|
+
FINALLY_RETURN_RULE,
|
|
11
14
|
FLOATING_PROMISE_MESSAGE,
|
|
12
15
|
FLOATING_PROMISE_ORIGIN,
|
|
13
16
|
FLOATING_PROMISE_RULE,
|
|
@@ -53,7 +56,7 @@ import {
|
|
|
53
56
|
resultLookalikeMessage,
|
|
54
57
|
svelteFor,
|
|
55
58
|
trustDirectivesIn
|
|
56
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-4XGOH7JE.js";
|
|
57
60
|
|
|
58
61
|
// src/core/guard.ts
|
|
59
62
|
function unparen(ts, node) {
|
|
@@ -1820,6 +1823,29 @@ function acceptDirectiveFindings(ts, sourceFile, context) {
|
|
|
1820
1823
|
return found;
|
|
1821
1824
|
}
|
|
1822
1825
|
|
|
1826
|
+
// src/core/finally-returns.ts
|
|
1827
|
+
function isScopeBoundary(ts, node) {
|
|
1828
|
+
return isFunctionBoundary(ts, node) || ts.isClassLike(node) || ts.isClassStaticBlockDeclaration(node);
|
|
1829
|
+
}
|
|
1830
|
+
function finallyReturnsIn(ts, sourceFile) {
|
|
1831
|
+
const found = [];
|
|
1832
|
+
const visit = (node, inFinally) => {
|
|
1833
|
+
if (inFinally && ts.isReturnStatement(node)) {
|
|
1834
|
+
found.push({ start: node.getStart(sourceFile) });
|
|
1835
|
+
}
|
|
1836
|
+
if (ts.isTryStatement(node)) {
|
|
1837
|
+
visit(node.tryBlock, inFinally);
|
|
1838
|
+
if (node.catchClause) visit(node.catchClause, inFinally);
|
|
1839
|
+
if (node.finallyBlock) visit(node.finallyBlock, true);
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
const nextInFinally = isScopeBoundary(ts, node) ? false : inFinally;
|
|
1843
|
+
ts.forEachChild(node, (child) => visit(child, nextInFinally));
|
|
1844
|
+
};
|
|
1845
|
+
visit(sourceFile, false);
|
|
1846
|
+
return found;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1823
1849
|
// src/core/redundant-guards.ts
|
|
1824
1850
|
var ORIGIN_LIMIT = 3;
|
|
1825
1851
|
function redundantGuardData(guard) {
|
|
@@ -3603,6 +3629,11 @@ function checkSourceFileWithAccepted(options) {
|
|
|
3603
3629
|
reportAt(guard.start, REDUNDANT_GUARD_RULE, REDUNDANT_GUARD_ORIGIN, redundantGuardMessage(guard));
|
|
3604
3630
|
}
|
|
3605
3631
|
}
|
|
3632
|
+
if (isRuleEnabled(config, FINALLY_RETURN_RULE)) {
|
|
3633
|
+
for (const found of finallyReturnsIn(ts, sourceFile)) {
|
|
3634
|
+
reportAt(found.start, FINALLY_RETURN_RULE, FINALLY_RETURN_ORIGIN, FINALLY_RETURN_MESSAGES.return);
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3606
3637
|
if (config.boundaries.length > 0) {
|
|
3607
3638
|
for (const found of boundaryFindingsIn(sourceFile, boundaryContext(ts, checker, options.program, policy, config), strict)) {
|
|
3608
3639
|
const finding = findingAt(found.start, BOUNDARY_RULE, found.origin, boundaryMessage(found));
|
|
@@ -3640,6 +3671,7 @@ export {
|
|
|
3640
3671
|
untrustedCallProblem,
|
|
3641
3672
|
acceptanceOf,
|
|
3642
3673
|
acceptDirectiveFindings,
|
|
3674
|
+
finallyReturnsIn,
|
|
3643
3675
|
redundantGuardData,
|
|
3644
3676
|
redundantGuardsIn,
|
|
3645
3677
|
trustedStateContext,
|
|
@@ -3665,4 +3697,4 @@ export {
|
|
|
3665
3697
|
checkSourceFile,
|
|
3666
3698
|
checkSourceFileWithAccepted
|
|
3667
3699
|
};
|
|
3668
|
-
//# sourceMappingURL=chunk-
|
|
3700
|
+
//# sourceMappingURL=chunk-35ETSKEC.js.map
|