candor-ts 0.5.22 → 0.5.23
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 +1 -1
- package/scan-core.mjs +57 -0
- package/scan.mjs +17 -1
package/package.json
CHANGED
package/scan-core.mjs
CHANGED
|
@@ -66,11 +66,60 @@ export const KAPPA_RULES = [
|
|
|
66
66
|
[/^(node:)?sqlite$/, null, "Db"],
|
|
67
67
|
// the curated npm tier
|
|
68
68
|
[/^(axios|got|node-fetch|undici|ws|socket\.io(-client)?|nodemailer)$/, null, "Net"],
|
|
69
|
+
// gaxios is the axios-like HTTP client under googleapis (request/get/post/put/patch/delete/head do
|
|
70
|
+
// the network; it has no notable pure surface, but be VERB-precise like the rest of the Net tier so a
|
|
71
|
+
// future config accessor can't fabricate). `createAPIRequest` is googleapis-common's transport entry
|
|
72
|
+
// (every googleapis service method funnels through it → the real network). The deeper `googleapis`
|
|
73
|
+
// service chains (`calendar.events.insert()`) resolve their verb into the `googleapis` package, but
|
|
74
|
+
// those verbs are GENERIC (insert/list/get/update) and shared with pure builders — modeling them by
|
|
75
|
+
// name would fabricate; the actual network is the gaxios/createAPIRequest transport, modeled here, so
|
|
76
|
+
// a googleapis call that reaches the wire does so through a modeled unit when its source is scanned.
|
|
77
|
+
[/^gaxios$/, /^(request|get|post|put|patch|delete|head)$/, "Net"],
|
|
78
|
+
[/^googleapis-common$/, /^createAPIRequest$/, "Net"],
|
|
79
|
+
// google-auth-library mints/refreshes OAuth tokens and verifies ID tokens over the network. The
|
|
80
|
+
// verb surface only (the GoogleAuth/OAuth2Client/JWT constructors are config — inert until a verb).
|
|
81
|
+
[/^google-auth-library$/,
|
|
82
|
+
/^(request|getClient|getAccessToken|getRequestHeaders|authorize|refreshAccessToken|refreshToken|getTokenInfo|verifyIdToken|fetchIdToken|getCredentials|getProjectId|getSignedJwt)$/,
|
|
83
|
+
"Net"],
|
|
84
|
+
// stripe: methods land on a `new Stripe()` instance's resource chains
|
|
85
|
+
// (`stripe.customers.create()`, `stripe.checkout.sessions.create()`, `charges.*`, `paymentIntents.*`).
|
|
86
|
+
// A chained member call resolves its verb's DECLARATION into the `stripe` package (declModule keys on
|
|
87
|
+
// the source file, not the chain depth — verified), so keying on stripe's resource VERBS catches the
|
|
88
|
+
// deep chains. VERB-precise: the I/O verbs only (the SDK's resources share these); pure helpers
|
|
89
|
+
// (toString/JSON) and inert `new Stripe()` construction stay pure.
|
|
90
|
+
[/^stripe$/,
|
|
91
|
+
/^(create|retrieve|update|list|listLineItems|listPaymentMethods|del|delete|cancel|capture|confirm|expire|finalizeInvoice|pay|sendInvoice|markUncollectible|voidInvoice|refund|reverse|verify|search|approve|decline|attach|detach|deactivate)$/,
|
|
92
|
+
"Net"],
|
|
93
|
+
// error/telemetry SaaS — the capture/flush verbs ship the payload over the network. init/config are
|
|
94
|
+
// inert. @sentry/* re-exports captureException etc. from @sentry/core/@sentry/browser, so a consumer's
|
|
95
|
+
// import may resolve into any @sentry sub-package — match the whole scope, verb-precise.
|
|
96
|
+
[/^@sentry\/[^/]+$/,
|
|
97
|
+
/^(captureException|captureMessage|captureEvent|captureCheckIn|flush|close)$/, "Net"],
|
|
98
|
+
// posthog-node: capture/identify/group enqueue then flush over HTTP; flush/shutdown/captureImmediate
|
|
99
|
+
// and the feature-flag fetches (isFeatureEnabled/getFeatureFlag*) hit the API. Verb-precise; the
|
|
100
|
+
// `new PostHog()` ctor is inert (config).
|
|
101
|
+
[/^posthog-node$/,
|
|
102
|
+
/^(capture|captureImmediate|identify|identifyImmediate|alias|groupIdentify|flush|shutdown|isFeatureEnabled|getFeatureFlag|getFeatureFlagPayload|getAllFlags|getAllFlagsAndPayloads|getRemoteConfigPayload|reloadFeatureFlags)$/,
|
|
103
|
+
"Net"],
|
|
69
104
|
[/^(pg|mysql2?|mongodb|ioredis|redis|sqlite3|better-sqlite3|knex)$/, null, "Db"],
|
|
105
|
+
// bull/bullmq are Redis-backed job queues — the queue/worker/job ops issue Redis commands (Db). Their
|
|
106
|
+
// surface is almost entirely I/O, but be VERB-precise (the I/O ops) so inert event-wiring
|
|
107
|
+
// (`queue.on(...)`) and `new Queue()`/`new Worker()` construction (which only opens a lazy connection)
|
|
108
|
+
// don't fabricate. The connection IS Redis — Db, consistent with the ioredis/redis classification.
|
|
109
|
+
[/^(bull|bullmq)$/,
|
|
110
|
+
/^(add|addBulk|getJob|getJobs|getJobCounts|getJobCountByTypes|getWaiting|getActive|getCompleted|getFailed|getDelayed|getWaitingChildren|getRepeatableJobs|removeRepeatable|removeRepeatableByKey|getMetrics|count|pause|resume|isPaused|drain|clean|obliterate|empty|close|remove|retry|retryJobs|promote|moveToCompleted|moveToFailed|updateData|updateProgress|process|waitUntilReady|getState|getDependencies|getChildrenValues)$/,
|
|
111
|
+
"Db"],
|
|
70
112
|
[/^(execa|cross-spawn|shelljs)$/, null, "Exec"],
|
|
113
|
+
// the `open` package spawns the OS handler (xdg-open/open/start) — Exec. Default export `open(target)`
|
|
114
|
+
// resolves to member `open` (its declared fn name — verified); `openApp` likewise. The `apps` const is
|
|
115
|
+
// pure (a property read, never a call).
|
|
116
|
+
[/^open$/, /^(open|openApp)$/, "Exec"],
|
|
71
117
|
[/^(fs-extra|graceful-fs|rimraf|glob|chokidar)$/, null, "Fs"],
|
|
72
118
|
[/^dotenv$/, null, "Env"],
|
|
73
119
|
[/^(winston|pino|bunyan|npmlog)$/, null, "Log"],
|
|
120
|
+
// nest-winston wraps winston; the injected logger's level verbs are the Log boundary (the
|
|
121
|
+
// WinstonModule.createLogger/forRoot config is inert).
|
|
122
|
+
[/^nest-winston$/, /^(log|info|warn|error|debug|verbose|silly|http)$/, "Log"],
|
|
74
123
|
// entropy: node:crypto's random surface + the password-hashing libs (salted -> Rand). Found by
|
|
75
124
|
// the CTA dogfood on a Nest app: argon2.hash came out SILENTLY PURE (the curated-kappa caveat
|
|
76
125
|
// landing on exactly the call a security review cares about).
|
|
@@ -78,6 +127,14 @@ export const KAPPA_RULES = [
|
|
|
78
127
|
// were silently pure inside the covered `crypto` module (the κ-coverage floor can't tell an unmodeled
|
|
79
128
|
// entropy draw from a pure unmodeled member; the fix is to MODEL the member, not drop coverage).
|
|
80
129
|
[/^(node:)?crypto$/, /^(random|getRandomValues|generateKey|generatePrime)/, "Rand"],
|
|
130
|
+
// uuid: the random-based generators draw from the CSPRNG (v4) / clock+MAC+random (v1) / random (v6/v7).
|
|
131
|
+
// v3 (MD5) and v5 (SHA-1) are DETERMINISTIC namespace hashes — same input, same UUID — so they are
|
|
132
|
+
// PURE and excluded. parse/stringify/validate/version/NIL/MAX are pure too (not matched).
|
|
133
|
+
[/^uuid$/, /^(v1|v4|v6|v7)$/, "Rand"],
|
|
134
|
+
// nanoid: nanoid()/customRandom() draw from crypto.getRandomValues; customAlphabet() returns a
|
|
135
|
+
// generator that does the same. `nanoid/non-secure` uses Math.random — still Rand. The `urlAlphabet`
|
|
136
|
+
// const is pure (a property read). Sound over-approximation: the factory call is the resolvable site.
|
|
137
|
+
[/^nanoid(\/non-secure)?$/, /^(nanoid|customAlphabet|customRandom)$/, "Rand"],
|
|
81
138
|
// node:os identity reads — userInfo (the OS user record) and hostname (the machine name) are
|
|
82
139
|
// environment/host reads (Env), like System.getenv's host-identity cousins. The rest of node:os
|
|
83
140
|
// (platform/arch/cpus/totalmem/…) is inert host introspection, left pure.
|
package/scan.mjs
CHANGED
|
@@ -1453,9 +1453,25 @@ function visitCalls(node) {
|
|
|
1453
1453
|
: (decl.name ? decl.name.getText() : ""))
|
|
1454
1454
|
: "";
|
|
1455
1455
|
const isConstruction = ts.isConstructorDeclaration(decl) || ts.isNewExpression(node);
|
|
1456
|
+
// The κ member token. A named decl (function/method declaration) carries its own name; but a
|
|
1457
|
+
// VALUE-BINDING export — `export const v4 = (...) => ...` (the shape REAL uuid v9+/nanoid ship,
|
|
1458
|
+
// and the `type v4 = v4Buffer & v4String` callable type-alias of @types/uuid v8) resolves to an
|
|
1459
|
+
// ANONYMOUS arrow/function-type whose `decl.name` is empty, so κ saw `""` and the package's
|
|
1460
|
+
// entropy/net verb read silent-pure (verified against installed uuid/nanoid). Fall back to the
|
|
1461
|
+
// BINDING name: an arrow/fn-expr's parent VariableDeclaration / PropertyAssignment / property,
|
|
1462
|
+
// or a callable type-alias's TypeAliasDeclaration. Precision no-op where the old path already
|
|
1463
|
+
// had a name (this only fills a former `""`); never synthesizes a name for `new`.
|
|
1464
|
+
const bindingName = (d) => {
|
|
1465
|
+
const p = d.parent;
|
|
1466
|
+
if (!p) return "";
|
|
1467
|
+
if ((ts.isVariableDeclaration(p) || ts.isPropertyDeclaration(p) || ts.isPropertyAssignment(p)
|
|
1468
|
+
|| ts.isPropertySignature(p) || ts.isBindingElement(p) || ts.isTypeAliasDeclaration(p))
|
|
1469
|
+
&& p.name && ts.isIdentifier(p.name)) return p.name.getText();
|
|
1470
|
+
return "";
|
|
1471
|
+
};
|
|
1456
1472
|
const member = isConstruction
|
|
1457
1473
|
? (CONNECTING_CTORS.has(ctorClassName) ? ctorClassName : "new")
|
|
1458
|
-
: (decl.name ? decl.name.getText() :
|
|
1474
|
+
: (decl.name ? decl.name.getText() : bindingName(decl));
|
|
1459
1475
|
let eff = kappa(mod, member); // (CLASSIFY)
|
|
1460
1476
|
// process.stdout/stderr/stdin are typed `tty.WriteStream`, which EXTENDS `net.Socket`, so a
|
|
1461
1477
|
// `.write()`/`.end()` on them resolves to `net.Socket.write` and the whole-module Net rule
|