@r_masseater/h56m 0.0.0 → 0.1.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/LICENSE +87 -0
- package/README.md +30 -1
- package/THIRD-PARTY-NOTICES.txt +1270 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +41 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index-DiF7IoP4.d.mts +52 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.mjs +1 -0
- package/dist/section-AeJ2zzPN.mjs +209 -0
- package/dist/section-AeJ2zzPN.mjs.map +1 -0
- package/dist/vite.d.mts +7 -0
- package/dist/vite.mjs +1 -0
- package/package.json +89 -5
- package/skills/scan-secrets/SKILL.md +83 -0
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { a as failedWith, n as format, o as runTool, r as makeDetector, t as h56mSection } from "./section-AeJ2zzPN.mjs";
|
|
3
|
+
import { Array, Boolean, Effect } from "effect";
|
|
4
|
+
// src/app/cli.ts
|
|
5
|
+
const STAGED = "--staged";
|
|
6
|
+
const BASES = [
|
|
7
|
+
"origin/HEAD",
|
|
8
|
+
"origin/main",
|
|
9
|
+
"origin/master"
|
|
10
|
+
];
|
|
11
|
+
const HEAD = "HEAD";
|
|
12
|
+
const candidatesOf = (requested) => Array.match(requested, {
|
|
13
|
+
onEmpty: () => BASES,
|
|
14
|
+
onNonEmpty: (given) => given
|
|
15
|
+
});
|
|
16
|
+
const sourceOf = (requested) => Boolean.match(Array.contains(requested, STAGED), {
|
|
17
|
+
onTrue: () => ({ type: "staged" }),
|
|
18
|
+
onFalse: () => ({
|
|
19
|
+
type: "history",
|
|
20
|
+
bases: candidatesOf(requested),
|
|
21
|
+
head: HEAD
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
const scan = ({ root, config, args }) => makeDetector(config).pipe(Effect.flatMap((detector) => detector.scanGit({
|
|
25
|
+
root,
|
|
26
|
+
source: sourceOf(args)
|
|
27
|
+
})));
|
|
28
|
+
const runCli = () => {
|
|
29
|
+
runTool({
|
|
30
|
+
name: "h56m",
|
|
31
|
+
section: h56mSection,
|
|
32
|
+
failWith: failedWith,
|
|
33
|
+
scan,
|
|
34
|
+
format
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
// bin/h56m.ts
|
|
38
|
+
runCli();
|
|
39
|
+
export {};
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["Arr","Bool"],"sources":["../src/app/cli.ts","../bin/h56m.ts"],"sourcesContent":["import { runTool } from \"@masseater.dev/lint-host\";\nimport type { ToolCall } from \"@masseater.dev/lint-host\";\nimport { Array as Arr, Boolean as Bool, Effect } from \"effect\";\n\nimport type { Finding, GitSource, H56mConfig } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { H56mError } from \"#/shared/lib/errors.ts\";\n\nimport { makeDetector } from \"./detector.ts\";\nimport { format } from \"./format.ts\";\nimport { h56mSection } from \"./section.ts\";\n\nconst STAGED = \"--staged\";\nconst BASES = [\"origin/HEAD\", \"origin/main\", \"origin/master\"];\nconst HEAD = \"HEAD\";\n\nconst candidatesOf = (requested: readonly string[]): readonly string[] =>\n Arr.match(requested, { onEmpty: () => BASES, onNonEmpty: (given) => given });\n\nconst sourceOf = (requested: readonly string[]): GitSource =>\n Bool.match(Arr.contains(requested, STAGED), {\n onTrue: (): GitSource => ({ type: \"staged\" }),\n onFalse: (): GitSource => ({ type: \"history\", bases: candidatesOf(requested), head: HEAD }),\n });\n\nconst scan = ({\n root,\n config,\n args,\n}: ToolCall<H56mConfig>): Effect.Effect<readonly Finding[], H56mError> =>\n makeDetector(config).pipe(\n Effect.flatMap((detector) => detector.scanGit({ root, source: sourceOf(args) })),\n );\n\nexport const runCli = (): void => {\n runTool({ name: \"h56m\", section: h56mSection, failWith: failedWith, scan, format });\n};\n","#!/usr/bin/env node\nimport { runCli } from \"#/app/cli.ts\";\n\nrunCli();\n"],"mappings":";;;;AAYA,MAAM,SAAS;AACf,MAAM,QAAQ;CAAC;CAAe;CAAe;AAAe;AAC5D,MAAM,OAAO;AAEb,MAAM,gBAAgB,cACpBA,MAAI,MAAM,WAAW;CAAE,eAAe;CAAO,aAAa,UAAU;AAAM,CAAC;AAE7E,MAAM,YAAY,cAChBC,QAAK,MAAMD,MAAI,SAAS,WAAW,MAAM,GAAG;CAC1C,eAA0B,EAAE,MAAM,SAAS;CAC3C,gBAA2B;EAAE,MAAM;EAAW,OAAO,aAAa,SAAS;EAAG,MAAM;CAAK;AAC3F,CAAC;AAEH,MAAM,QAAQ,EACZ,MACA,QACA,WAEA,aAAa,MAAM,CAAC,CAAC,KACnB,OAAO,SAAS,aAAa,SAAS,QAAQ;CAAE;CAAM,QAAQ,SAAS,IAAI;AAAE,CAAC,CAAC,CACjF;AAEF,MAAa,eAAqB;CAChC,QAAQ;EAAE,MAAM;EAAQ,SAAS;EAAa,UAAU;EAAY;EAAM;CAAO,CAAC;AACpF;;ACjCA,OAAO"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
interface H56mRule {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly description?: string;
|
|
5
|
+
readonly keywords?: readonly string[];
|
|
6
|
+
readonly regex?: string;
|
|
7
|
+
readonly path?: string;
|
|
8
|
+
readonly valueGroup?: number;
|
|
9
|
+
readonly specificity?: number;
|
|
10
|
+
readonly tags?: readonly string[];
|
|
11
|
+
readonly skipReport?: boolean;
|
|
12
|
+
readonly filter?: string;
|
|
13
|
+
readonly confidence?: "low" | "medium" | "high";
|
|
14
|
+
}
|
|
15
|
+
interface H56mExtend {
|
|
16
|
+
readonly path?: string;
|
|
17
|
+
readonly disabledRules?: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
interface H56mConfig {
|
|
20
|
+
readonly extend?: H56mExtend;
|
|
21
|
+
readonly prefilter?: string;
|
|
22
|
+
readonly filter?: string;
|
|
23
|
+
readonly rules?: readonly H56mRule[];
|
|
24
|
+
readonly ignoredSecrets?: readonly string[];
|
|
25
|
+
}
|
|
26
|
+
declare const FindingSchema: Schema.Struct<{
|
|
27
|
+
readonly rule: Schema.String;
|
|
28
|
+
readonly description: Schema.String;
|
|
29
|
+
readonly confidence: Schema.Literals<readonly ["low", "medium", "high"]>;
|
|
30
|
+
readonly path: Schema.String;
|
|
31
|
+
readonly line: Schema.Int;
|
|
32
|
+
readonly column: Schema.Int;
|
|
33
|
+
readonly endLine: Schema.Int;
|
|
34
|
+
readonly endColumn: Schema.Int;
|
|
35
|
+
readonly secret: Schema.String;
|
|
36
|
+
readonly digest: Schema.String;
|
|
37
|
+
readonly commit: Schema.optionalKey<Schema.String>;
|
|
38
|
+
readonly encoded: Schema.Boolean;
|
|
39
|
+
}>;
|
|
40
|
+
type Finding = typeof FindingSchema.Type;
|
|
41
|
+
type GitSource = {
|
|
42
|
+
readonly type: "history";
|
|
43
|
+
readonly bases?: readonly string[];
|
|
44
|
+
readonly head: string;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: "staged";
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "snapshot";
|
|
49
|
+
readonly revision: string;
|
|
50
|
+
};
|
|
51
|
+
export { H56mRule as a, H56mExtend as i, GitSource as n, H56mConfig as r, Finding as t };
|
|
52
|
+
//# sourceMappingURL=index-DiF7IoP4.d.mts.map
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { a as H56mRule, i as H56mExtend, n as GitSource, r as H56mConfig, t as Finding } from "./index-DiF7IoP4.mjs";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
declare const H56mError_base: Schema.Class<H56mError, Schema.TaggedStruct<"H56mError", {
|
|
4
|
+
readonly message: Schema.String;
|
|
5
|
+
}>, import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly brand: unique symbol;
|
|
7
|
+
}>;
|
|
8
|
+
export declare class H56mError extends H56mError_base {}
|
|
9
|
+
interface TextScan {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
interface GitScan {
|
|
14
|
+
readonly root: string;
|
|
15
|
+
readonly source: GitSource;
|
|
16
|
+
}
|
|
17
|
+
interface Detector {
|
|
18
|
+
readonly scanText: (scan: TextScan) => Effect.Effect<readonly Finding[], H56mError>;
|
|
19
|
+
readonly scanGit: (scan: GitScan) => Effect.Effect<readonly Finding[], H56mError>;
|
|
20
|
+
}
|
|
21
|
+
export declare const makeDetector: (config?: H56mConfig | undefined) => Effect.Effect<Detector, H56mError, never>;
|
|
22
|
+
export declare const format: (finding: Finding) => string;
|
|
23
|
+
export declare const h56mSection: (config: unknown) => H56mConfig;
|
|
24
|
+
export type { Detector, Finding, GitScan, GitSource, H56mConfig, H56mExtend, H56mRule, TextScan };
|
|
25
|
+
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { i as H56mError, n as format, t as h56mSection, r as makeDetector } from "./section-AeJ2zzPN.mjs";
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { Array, Boolean, Console, Effect, FileSystem, Function, Layer, Match, Option, Order, Path, Predicate, Record, Schema, String as String$1, pipe } from "effect";
|
|
3
|
+
import { NodeServices } from "@effect/platform-node";
|
|
4
|
+
import { runMain } from "@effect/platform-node/NodeRuntime";
|
|
5
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
6
|
+
import { FetchHttpClient } from "effect/http";
|
|
7
|
+
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
8
|
+
import { resolveConfigFromFile } from "vite-plus";
|
|
9
|
+
// ../lint-host/src/shared/lib/target.ts
|
|
10
|
+
const abiOf = (platform) => Match.value(platform).pipe(Match.when("linux", () => "-gnu"), Match.when("win32", () => "-msvc"), Match.orElse(() => ""));
|
|
11
|
+
const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;
|
|
12
|
+
const addonFileOf = (binary) => `${binary}.${platformTarget}.node`;
|
|
13
|
+
// ../lint-host/src/features/build-addon/model/build.ts
|
|
14
|
+
const taggedError$1 = Schema.TaggedError;
|
|
15
|
+
var AddonBuildFailed = class extends taggedError$1()("AddonBuildFailed", { message: Schema.String }) {};
|
|
16
|
+
const LIBRARY = {
|
|
17
|
+
linux: (name) => `lib${name}.so`,
|
|
18
|
+
darwin: (name) => `lib${name}.dylib`,
|
|
19
|
+
win32: (name) => `${name}.dll`
|
|
20
|
+
};
|
|
21
|
+
const SUCCESS = 0;
|
|
22
|
+
const cargo = Effect.fn("cargo")(function* cargo(crate, workspace) {
|
|
23
|
+
const exitCode = yield* (yield* ChildProcessSpawner.ChildProcessSpawner).exitCode(ChildProcess.make("cargo", [
|
|
24
|
+
"build",
|
|
25
|
+
"--release",
|
|
26
|
+
"--locked",
|
|
27
|
+
"-p",
|
|
28
|
+
crate
|
|
29
|
+
], {
|
|
30
|
+
cwd: workspace,
|
|
31
|
+
stdout: "inherit",
|
|
32
|
+
stderr: "inherit"
|
|
33
|
+
}));
|
|
34
|
+
const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });
|
|
35
|
+
yield* Effect.when(Effect.fail(failure), Effect.sync(() => Number(exitCode) !== SUCCESS));
|
|
36
|
+
});
|
|
37
|
+
Effect.fn("buildAddon")(function* build(options) {
|
|
38
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
39
|
+
const path = yield* Path.Path;
|
|
40
|
+
const library = yield* Effect.fromOption(Record.get(LIBRARY, process.platform)).pipe(Effect.mapError(() => AddonBuildFailed.make({ message: `no native build for ${process.platform}` })));
|
|
41
|
+
yield* cargo(options.crate, options.workspaceDir);
|
|
42
|
+
const output = path.join(options.packageDir, "native");
|
|
43
|
+
yield* fileSystem.makeDirectory(output, { recursive: true });
|
|
44
|
+
const built = library(String$1.replaceAll("-", "_")(options.crate));
|
|
45
|
+
yield* fileSystem.copyFile(path.join(options.workspaceDir, "target", "release", built), path.join(output, addonFileOf(options.binary)));
|
|
46
|
+
});
|
|
47
|
+
// ../lint-host/src/features/load-addon/model/load.ts
|
|
48
|
+
const loadAddon = ({ packageName, binary, from, isAddon, failWith }) => {
|
|
49
|
+
const requireFrom = createRequire(from);
|
|
50
|
+
const loadFrom = (specifier) => Effect.try({
|
|
51
|
+
try: () => requireFrom(specifier),
|
|
52
|
+
catch: failWith(`could not load ${specifier}`)
|
|
53
|
+
});
|
|
54
|
+
return loadFrom(`${packageName}-${platformTarget}`).pipe(Effect.catchCause(() => loadFrom(`${packageName}/native/${addonFileOf(binary)}`)), Effect.filterOrFail(isAddon, (found) => failWith(`no ${binary} addon for ${platformTarget}`)(found)));
|
|
55
|
+
};
|
|
56
|
+
const callAddon = ({ addon, name, files, call, failWith }) => addon.pipe(Effect.flatMap((loaded) => Effect.try({
|
|
57
|
+
try: () => call(loaded),
|
|
58
|
+
catch: failWith(`${name} could not lint`)
|
|
59
|
+
}).pipe(Effect.tap(() => Effect.promise(() => loaded.flushTelemetry())))), Effect.withSpan(`${name}.native`, { attributes: { [`${name}.files`]: files } }));
|
|
60
|
+
// ../lint-host/src/features/run-cli/model/cli.ts
|
|
61
|
+
const CONFIG_FILES = [
|
|
62
|
+
"vite.config.ts",
|
|
63
|
+
"vite.config.mts",
|
|
64
|
+
"vite.config.js",
|
|
65
|
+
"vite.config.mjs"
|
|
66
|
+
];
|
|
67
|
+
const FAILED = 1;
|
|
68
|
+
const DATA_FIRST_ARITY$1 = 2;
|
|
69
|
+
const ARGUMENTS_START = 2;
|
|
70
|
+
const readSectionIn = (source, root) => Effect.gen(function* readConfig() {
|
|
71
|
+
const fileSystem = yield* FileSystem.FileSystem;
|
|
72
|
+
const path = yield* Path.Path;
|
|
73
|
+
const found = yield* pipe(CONFIG_FILES, Array.map((name) => path.join(root, name)), Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))));
|
|
74
|
+
const loaded = yield* Option.match(Array.head(found), {
|
|
75
|
+
onNone: () => Effect.succeed({}),
|
|
76
|
+
onSome: (file) => Effect.tryPromise({
|
|
77
|
+
try: () => resolveConfigFromFile(file),
|
|
78
|
+
catch: source.failWith(`could not load ${file}`)
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
return source.section(loaded);
|
|
82
|
+
}).pipe(Effect.withSpan(`${source.name}.config`));
|
|
83
|
+
Function.dual(DATA_FIRST_ARITY$1, readSectionIn);
|
|
84
|
+
const failWhen = (failed) => Effect.when(Effect.sync(() => {
|
|
85
|
+
process.exitCode = FAILED;
|
|
86
|
+
}), Effect.succeed(failed)).pipe(Effect.asVoid);
|
|
87
|
+
const printAll = (found, format) => Array.match(found, {
|
|
88
|
+
onEmpty: () => Effect.void,
|
|
89
|
+
onNonEmpty: (all) => Console.log(pipe(all, Array.map(format), Array.join("\n")))
|
|
90
|
+
});
|
|
91
|
+
const toolMainOf = (tool) => Effect.gen(function* main() {
|
|
92
|
+
const root = process.cwd();
|
|
93
|
+
const config = yield* readSectionIn(tool, root);
|
|
94
|
+
const found = yield* tool.scan({
|
|
95
|
+
root,
|
|
96
|
+
config,
|
|
97
|
+
args: process.argv.slice(ARGUMENTS_START)
|
|
98
|
+
});
|
|
99
|
+
yield* printAll(found, tool.format);
|
|
100
|
+
yield* failWhen(Array.isReadonlyArrayNonEmpty(found));
|
|
101
|
+
});
|
|
102
|
+
const runTraced = (name, program) => {
|
|
103
|
+
const services = Otlp.layerFromConfig({ resource: { serviceName: name } }).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer), Layer.provideMerge(NodeServices.layer));
|
|
104
|
+
runMain(program.pipe(Effect.provide(services)));
|
|
105
|
+
};
|
|
106
|
+
const runTool = (tool) => {
|
|
107
|
+
runTraced(tool.name, toolMainOf(tool));
|
|
108
|
+
};
|
|
109
|
+
Function.dual(2, (value, build) => Option.match(value, {
|
|
110
|
+
onNone: () => ({}),
|
|
111
|
+
onSome: build
|
|
112
|
+
}));
|
|
113
|
+
// ../lint-host/src/shared/lib/trace.ts
|
|
114
|
+
const SAMPLED = "01";
|
|
115
|
+
const NOT_SAMPLED = "00";
|
|
116
|
+
const flagsOf = (sampled) => Boolean.match(sampled, {
|
|
117
|
+
onFalse: () => NOT_SAMPLED,
|
|
118
|
+
onTrue: () => SAMPLED
|
|
119
|
+
});
|
|
120
|
+
const traceparent = Effect.currentSpan.pipe(Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`), Effect.option);
|
|
121
|
+
Order.combine(Order.mapInput(Order.String, (found) => found.path), Order.mapInput(Order.Number, (found) => found.line));
|
|
122
|
+
// src/shared/config/types.ts
|
|
123
|
+
const FindingSchema = Schema.Struct({
|
|
124
|
+
rule: Schema.String,
|
|
125
|
+
description: Schema.String,
|
|
126
|
+
confidence: Schema.Literals([
|
|
127
|
+
"low",
|
|
128
|
+
"medium",
|
|
129
|
+
"high"
|
|
130
|
+
]),
|
|
131
|
+
path: Schema.String,
|
|
132
|
+
line: Schema.Int,
|
|
133
|
+
column: Schema.Int,
|
|
134
|
+
endLine: Schema.Int,
|
|
135
|
+
endColumn: Schema.Int,
|
|
136
|
+
secret: Schema.String,
|
|
137
|
+
digest: Schema.String,
|
|
138
|
+
commit: Schema.optionalKey(Schema.String),
|
|
139
|
+
encoded: Schema.Boolean
|
|
140
|
+
});
|
|
141
|
+
// src/shared/lib/errors.ts
|
|
142
|
+
const taggedError = Schema.TaggedError;
|
|
143
|
+
var H56mError = class extends taggedError()("H56mError", { message: Schema.String }) {};
|
|
144
|
+
const failedWith = (message) => (cause) => H56mError.make({ message: `${message}: ${String(cause)}` });
|
|
145
|
+
// src/shared/native/index.ts
|
|
146
|
+
const isNative = (value) => Predicate.hasProperty(value, "SecretDetector") && Predicate.isFunction(value.SecretDetector) && Predicate.hasProperty(value, "flushTelemetry") && Predicate.isFunction(value.flushTelemetry);
|
|
147
|
+
const native = loadAddon({
|
|
148
|
+
packageName: "@r_masseater/h56m",
|
|
149
|
+
binary: "h56m",
|
|
150
|
+
from: import.meta.url,
|
|
151
|
+
isAddon: isNative,
|
|
152
|
+
failWith: failedWith
|
|
153
|
+
});
|
|
154
|
+
// src/app/detector.ts
|
|
155
|
+
const ONE_FILE = 1;
|
|
156
|
+
const WHOLE_REPOSITORY = 0;
|
|
157
|
+
const decodeFindings = Schema.decodeUnknownEffect(Schema.Array(FindingSchema));
|
|
158
|
+
const withParent = (input) => traceparent.pipe(Effect.map(Option.match({
|
|
159
|
+
onNone: () => input,
|
|
160
|
+
onSome: (value) => ({
|
|
161
|
+
...input,
|
|
162
|
+
traceparent: value
|
|
163
|
+
})
|
|
164
|
+
})));
|
|
165
|
+
const run = ({ name, files, call }) => callAddon({
|
|
166
|
+
addon: native,
|
|
167
|
+
name,
|
|
168
|
+
files,
|
|
169
|
+
call,
|
|
170
|
+
failWith: failedWith
|
|
171
|
+
}).pipe(Effect.flatMap((found) => decodeFindings(found).pipe(Effect.mapError(failedWith("h56m returned an unknown shape")))));
|
|
172
|
+
const scannerOf = (detector) => ({
|
|
173
|
+
scanText: (scan) => withParent(scan).pipe(Effect.flatMap((input) => run({
|
|
174
|
+
name: "h56m.text",
|
|
175
|
+
files: ONE_FILE,
|
|
176
|
+
call: () => detector.scan(input)
|
|
177
|
+
})), Effect.withSpan("h56m.scan_text")),
|
|
178
|
+
scanGit: (scan) => withParent(scan).pipe(Effect.flatMap((input) => run({
|
|
179
|
+
name: "h56m.git",
|
|
180
|
+
files: WHOLE_REPOSITORY,
|
|
181
|
+
call: () => detector.scanGit(input)
|
|
182
|
+
})), Effect.withSpan("h56m.scan_git", { attributes: { "h56m.source": scan.source.type } }))
|
|
183
|
+
});
|
|
184
|
+
const makeDetector = Effect.fn("h56m.detector")(function* makeDetector(config = {}) {
|
|
185
|
+
const { ignoredSecrets = [], ...rest } = config;
|
|
186
|
+
const input = yield* withParent({
|
|
187
|
+
config: rest,
|
|
188
|
+
ignored: ignoredSecrets
|
|
189
|
+
});
|
|
190
|
+
const detector = yield* callAddon({
|
|
191
|
+
addon: native,
|
|
192
|
+
name: "h56m",
|
|
193
|
+
files: WHOLE_REPOSITORY,
|
|
194
|
+
call: (addon) => new addon.SecretDetector(input),
|
|
195
|
+
failWith: failedWith
|
|
196
|
+
});
|
|
197
|
+
return scannerOf(detector);
|
|
198
|
+
});
|
|
199
|
+
// src/app/format.ts
|
|
200
|
+
const START = 0;
|
|
201
|
+
const SHORT_COMMIT = 12;
|
|
202
|
+
const commitOf = (finding) => pipe(Option.fromNullishOr(finding.commit), Option.map((commit) => ` (${String$1.slice(START, SHORT_COMMIT)(commit)})`), Option.getOrElse(() => ""));
|
|
203
|
+
const format = (finding) => `${finding.path}:${String(finding.line)}:${String(finding.column)} ${finding.rule} ${finding.description} sha256:${finding.digest}${commitOf(finding)}`;
|
|
204
|
+
// src/app/section.ts
|
|
205
|
+
const hasSection = (value) => Predicate.hasProperty(value, "h56m") && Predicate.isObject(value.h56m);
|
|
206
|
+
const h56mSection = (config) => pipe(Option.liftPredicate(config, hasSection), Option.map((value) => value.h56m), Option.getOrElse(() => ({})));
|
|
207
|
+
export { failedWith as a, H56mError as i, format as n, runTool as o, makeDetector as r, h56mSection as t };
|
|
208
|
+
|
|
209
|
+
//# sourceMappingURL=section-AeJ2zzPN.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-AeJ2zzPN.mjs","names":["taggedError","Rec","Str","DATA_FIRST_ARITY","Arr","Fn","Fn","Bool","Str"],"sources":["../../lint-host/src/shared/lib/target.ts","../../lint-host/src/features/build-addon/model/build.ts","../../lint-host/src/features/load-addon/model/load.ts","../../lint-host/src/features/run-cli/model/cli.ts","../../lint-host/src/shared/lib/present.ts","../../lint-host/src/shared/lib/trace.ts","../src/shared/config/types.ts","../src/shared/lib/errors.ts","../src/shared/native/index.ts","../src/app/detector.ts","../src/app/format.ts","../src/app/section.ts"],"sourcesContent":["import { Match } from \"effect\";\n\nconst abiOf = (platform: string): string =>\n Match.value(platform).pipe(\n Match.when(\"linux\", () => \"-gnu\"),\n Match.when(\"win32\", () => \"-msvc\"),\n Match.orElse(() => \"\"),\n );\n\nexport const platformTarget = `${process.platform}-${process.arch}${abiOf(process.platform)}`;\n\nexport const addonFileOf = (binary: string): string => `${binary}.${platformTarget}.node`;\n","import { NodeServices } from \"@effect/platform-node\";\nimport { runMain } from \"@effect/platform-node/NodeRuntime\";\nimport { Effect, FileSystem, Path, Record as Rec, Schema, String as Str } from \"effect\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { addonFileOf } from \"#/shared/lib/target.ts\";\n\nconst taggedError = Schema.TaggedError;\n\nclass AddonBuildFailed extends taggedError<AddonBuildFailed, { readonly brand: unique symbol }>()(\n \"AddonBuildFailed\",\n { message: Schema.String },\n) {}\n\nconst LIBRARY: Readonly<Record<string, (name: string) => string>> = {\n linux: (name) => `lib${name}.so`,\n darwin: (name) => `lib${name}.dylib`,\n win32: (name) => `${name}.dll`,\n};\n\nconst SUCCESS = 0;\n\nexport interface AddonBuild {\n readonly crate: string;\n readonly binary: string;\n readonly packageDir: string;\n readonly workspaceDir: string;\n}\n\nconst cargo = Effect.fn(\"cargo\")(function* cargo(crate: string, workspace: string) {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const exitCode = yield* spawner.exitCode(\n ChildProcess.make(\"cargo\", [\"build\", \"--release\", \"--locked\", \"-p\", crate], {\n cwd: workspace,\n stdout: \"inherit\",\n stderr: \"inherit\",\n }),\n );\n const failure = AddonBuildFailed.make({ message: `cargo exited with ${String(exitCode)}` });\n yield* Effect.when(\n Effect.fail(failure),\n Effect.sync(() => Number(exitCode) !== SUCCESS),\n );\n});\n\nconst build = Effect.fn(\"buildAddon\")(function* build(options: AddonBuild) {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const library = yield* Effect.fromOption(Rec.get(LIBRARY, process.platform)).pipe(\n Effect.mapError(() =>\n AddonBuildFailed.make({ message: `no native build for ${process.platform}` }),\n ),\n );\n yield* cargo(options.crate, options.workspaceDir);\n const output = path.join(options.packageDir, \"native\");\n yield* fileSystem.makeDirectory(output, { recursive: true });\n const built = library(Str.replaceAll(\"-\", \"_\")(options.crate));\n yield* fileSystem.copyFile(\n path.join(options.workspaceDir, \"target\", \"release\", built),\n path.join(output, addonFileOf(options.binary)),\n );\n});\n\nexport const buildAddon = (options: AddonBuild): void => {\n runMain(build(options).pipe(Effect.provide(NodeServices.layer)));\n};\n","import { createRequire } from \"node:module\";\n\nimport { Effect } from \"effect\";\n\nimport type { FailWith } from \"#/shared/lib/fail.ts\";\nimport { addonFileOf, platformTarget } from \"#/shared/lib/target.ts\";\n\nexport interface AddonSource<Addon, Failure> {\n readonly packageName: string;\n readonly binary: string;\n readonly from: string;\n readonly isAddon: (value: unknown) => value is Addon;\n readonly failWith: FailWith<Failure>;\n}\n\nexport const loadAddon = <Addon, Failure>({\n packageName,\n binary,\n from,\n isAddon,\n failWith,\n}: AddonSource<Addon, Failure>): Effect.Effect<Addon, Failure> => {\n const requireFrom = createRequire(from);\n const loadFrom = (specifier: string): Effect.Effect<unknown, Failure> =>\n Effect.try({\n try: (): unknown => requireFrom(specifier),\n catch: failWith(`could not load ${specifier}`),\n });\n return loadFrom(`${packageName}-${platformTarget}`).pipe(\n Effect.catchCause(() => loadFrom(`${packageName}/native/${addonFileOf(binary)}`)),\n Effect.filterOrFail(isAddon, (found) =>\n failWith(`no ${binary} addon for ${platformTarget}`)(found),\n ),\n );\n};\n\nexport interface Telemetered {\n readonly flushTelemetry: () => Promise<void>;\n}\n\nexport interface AddonCall<Addon extends Telemetered, Result, Failure> {\n readonly addon: Effect.Effect<Addon, Failure>;\n readonly name: string;\n readonly files: number;\n readonly call: (addon: Addon) => Result;\n readonly failWith: FailWith<Failure>;\n}\n\nexport const callAddon = <Addon extends Telemetered, Result, Failure>({\n addon,\n name,\n files,\n call,\n failWith,\n}: AddonCall<Addon, Result, Failure>): Effect.Effect<Result, Failure> =>\n addon.pipe(\n Effect.flatMap((loaded) =>\n Effect.try({ try: () => call(loaded), catch: failWith(`${name} could not lint`) }).pipe(\n Effect.tap(() => Effect.promise(() => loaded.flushTelemetry())),\n ),\n ),\n Effect.withSpan(`${name}.native`, { attributes: { [`${name}.files`]: files } }),\n );\n","import { NodeServices } from \"@effect/platform-node\";\nimport { runMain } from \"@effect/platform-node/NodeRuntime\";\nimport {\n Array as Arr,\n Console,\n Effect,\n FileSystem,\n Function as Fn,\n Layer,\n Option,\n Path,\n String as Str,\n pipe,\n} from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { Otlp, OtlpSerialization } from \"effect/observability\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport type { FailWith } from \"#/shared/lib/fail.ts\";\n\nconst CONFIG_FILES = [\"vite.config.ts\", \"vite.config.mts\", \"vite.config.js\", \"vite.config.mjs\"];\nconst FAILED = 1;\nconst DATA_FIRST_ARITY = 2;\nconst ARGUMENTS_START = 2;\n\nexport interface Reported {\n readonly severity: string;\n}\n\nexport interface LintCall<Config> {\n readonly root: string;\n readonly files: readonly string[];\n readonly projectFiles: readonly string[];\n readonly config: Config;\n}\n\nexport interface PathspecRequest<Config> {\n readonly config: Config;\n readonly patterns?: readonly string[];\n}\n\nexport interface SectionSource<Config, Failure> {\n readonly name: string;\n readonly section: (config: unknown) => Config;\n readonly failWith: FailWith<Failure>;\n}\n\nexport interface Cli<Config, Found extends Reported, Failure> extends SectionSource<\n Config,\n Failure\n> {\n readonly pathspecs: (request: PathspecRequest<Config>) => readonly string[];\n readonly lint: (call: LintCall<Config>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n}\n\nexport interface ToolCall<Config> {\n readonly root: string;\n readonly config: Config;\n readonly args: readonly string[];\n}\n\nexport interface Tool<Config, Found, Failure> extends SectionSource<Config, Failure> {\n readonly scan: (call: ToolCall<Config>) => Effect.Effect<readonly Found[], Failure>;\n readonly format: (found: Found) => string;\n}\n\ntype CliServices = FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner;\n\nconst readSectionIn = <Config, Failure>(\n source: SectionSource<Config, Failure>,\n root: string,\n): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path> =>\n Effect.gen(function* readConfig() {\n const fileSystem = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const found = yield* pipe(\n CONFIG_FILES,\n Arr.map((name) => path.join(root, name)),\n Effect.filter((file) => fileSystem.exists(file).pipe(Effect.orElseSucceed(() => false))),\n );\n const loaded = yield* Option.match(Arr.head(found), {\n onNone: () => Effect.succeed<unknown>({}),\n onSome: (file) =>\n Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: source.failWith(`could not load ${file}`),\n }),\n });\n return source.section(loaded);\n }).pipe(Effect.withSpan(`${source.name}.config`));\n\n/** @internal */\nexport const readSection: {\n (\n root: string,\n ): <Config, Failure>(\n source: SectionSource<Config, Failure>,\n ) => Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path>;\n <Config, Failure>(\n source: SectionSource<Config, Failure>,\n root: string,\n ): Effect.Effect<Config, Failure, FileSystem.FileSystem | Path.Path>;\n} = Fn.dual(DATA_FIRST_ARITY, readSectionIn);\n\nconst trackedFiles = (\n root: string,\n pathspecs: readonly string[],\n): Effect.Effect<readonly string[], PlatformError, ChildProcessSpawner.ChildProcessSpawner> =>\n Effect.gen(function* listFiles() {\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n const output = yield* spawner.string(\n ChildProcess.make(\n \"git\",\n [\"ls-files\", \"-co\", \"--exclude-standard\", \"-z\", \"--\", ...pathspecs],\n { cwd: root },\n ),\n );\n return pipe(Str.split(output, \"\\0\"), Arr.filter(Str.isNonEmpty));\n });\n\nconst requestOf = <Config>(config: Config, patterns: readonly string[]): PathspecRequest<Config> =>\n Arr.match(patterns, {\n onEmpty: () => ({ config }),\n onNonEmpty: (given) => ({ config, patterns: given }),\n });\n\nconst hasError = (found: readonly Reported[]): boolean =>\n pipe(\n found,\n Arr.some(({ severity }) => severity === \"error\"),\n );\n\nconst failWhen = (failed: boolean): Effect.Effect<void> =>\n Effect.when(\n Effect.sync(() => {\n process.exitCode = FAILED;\n }),\n Effect.succeed(failed),\n ).pipe(Effect.asVoid);\n\nconst printAll = <Found>(\n found: readonly Found[],\n format: (found: Found) => string,\n): Effect.Effect<void> =>\n Arr.match(found, {\n onEmpty: () => Effect.void,\n onNonEmpty: (all) => Console.log(pipe(all, Arr.map(format), Arr.join(\"\\n\"))),\n });\n\nconst mainOf = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n): Effect.Effect<void, Failure | PlatformError, CliServices> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* readSectionIn(cli, root);\n const patterns = process.argv.slice(ARGUMENTS_START);\n const files = yield* trackedFiles(root, cli.pathspecs(requestOf(config, patterns))).pipe(\n Effect.withSpan(`${cli.name}.files`),\n );\n const projectFiles = yield* trackedFiles(root, []).pipe(Effect.withSpan(`${cli.name}.project`));\n const found = yield* cli.lint({ root, files, projectFiles, config });\n yield* printAll(found, cli.format);\n yield* failWhen(hasError(found));\n });\n\nconst toolMainOf = <Config, Found, Failure>(\n tool: Tool<Config, Found, Failure>,\n): Effect.Effect<void, Failure | PlatformError, CliServices> =>\n Effect.gen(function* main() {\n const root = process.cwd();\n const config = yield* readSectionIn(tool, root);\n const found = yield* tool.scan({ root, config, args: process.argv.slice(ARGUMENTS_START) });\n yield* printAll(found, tool.format);\n yield* failWhen(Arr.isReadonlyArrayNonEmpty(found));\n });\n\nconst runTraced = <Failure>(\n name: string,\n program: Effect.Effect<void, Failure, CliServices>,\n): void => {\n const services = Otlp.layerFromConfig({ resource: { serviceName: name } }).pipe(\n Layer.provide(OtlpSerialization.layerJson),\n Layer.provide(FetchHttpClient.layer),\n Layer.provideMerge(NodeServices.layer),\n );\n runMain(program.pipe(Effect.provide(services)));\n};\n\nexport const runCli = <Config, Found extends Reported, Failure>(\n cli: Cli<Config, Found, Failure>,\n): void => {\n runTraced(cli.name, mainOf(cli));\n};\n\nexport const runTool = <Config, Found, Failure>(tool: Tool<Config, Found, Failure>): void => {\n runTraced(tool.name, toolMainOf(tool));\n};\n","import { Function as Fn, Option } from \"effect\";\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const present: {\n <Value, Fields extends object>(\n build: (value: Value) => Fields,\n ): (value: Option.Option<Value>) => Partial<Fields>;\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields>;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n <Value, Fields extends object>(\n value: Option.Option<Value>,\n build: (value: Value) => Fields,\n ): Partial<Fields> => Option.match(value, { onNone: (): Partial<Fields> => ({}), onSome: build }),\n);\n","import { Array as Arr, Boolean as Bool, Effect, Order } from \"effect\";\nimport type { Option } from \"effect\";\n\nconst SAMPLED = \"01\";\nconst NOT_SAMPLED = \"00\";\n\nexport interface Positioned {\n readonly path: string;\n readonly line: number;\n}\n\nconst flagsOf = (sampled: boolean): string =>\n Bool.match(sampled, { onFalse: () => NOT_SAMPLED, onTrue: () => SAMPLED });\n\nexport const traceparent: Effect.Effect<Option.Option<string>> = Effect.currentSpan.pipe(\n Effect.map((span) => `00-${span.traceId}-${span.spanId}-${flagsOf(span.sampled)}`),\n Effect.option,\n);\n\nconst byPosition: Order.Order<Positioned> = Order.combine(\n Order.mapInput(Order.String, (found: Positioned) => found.path),\n Order.mapInput(Order.Number, (found: Positioned) => found.line),\n);\n\nexport const sortByPosition = <Found extends Positioned>(found: readonly Found[]): Found[] =>\n Arr.sort(found, byPosition);\n","import { Schema } from \"effect\";\n\nexport interface H56mRule {\n readonly id: string;\n readonly description?: string;\n readonly keywords?: readonly string[];\n readonly regex?: string;\n readonly path?: string;\n readonly valueGroup?: number;\n readonly specificity?: number;\n readonly tags?: readonly string[];\n readonly skipReport?: boolean;\n readonly filter?: string;\n readonly confidence?: \"low\" | \"medium\" | \"high\";\n}\n\nexport interface H56mExtend {\n readonly path?: string;\n readonly disabledRules?: readonly string[];\n}\n\nexport interface H56mConfig {\n readonly extend?: H56mExtend;\n readonly prefilter?: string;\n readonly filter?: string;\n readonly rules?: readonly H56mRule[];\n readonly ignoredSecrets?: readonly string[];\n}\n\nexport const FindingSchema = Schema.Struct({\n rule: Schema.String,\n description: Schema.String,\n confidence: Schema.Literals([\"low\", \"medium\", \"high\"]),\n path: Schema.String,\n line: Schema.Int,\n column: Schema.Int,\n endLine: Schema.Int,\n endColumn: Schema.Int,\n secret: Schema.String,\n digest: Schema.String,\n commit: Schema.optionalKey(Schema.String),\n encoded: Schema.Boolean,\n});\n\nexport type Finding = typeof FindingSchema.Type;\n\nexport type GitSource =\n | { readonly type: \"history\"; readonly bases?: readonly string[]; readonly head: string }\n | { readonly type: \"staged\" }\n | { readonly type: \"snapshot\"; readonly revision: string };\n","import { Schema } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class H56mError extends taggedError<H56mError, { readonly brand: unique symbol }>()(\n \"H56mError\",\n { message: Schema.String },\n) {}\n\nexport const failedWith =\n (message: string) =>\n (cause: unknown): H56mError =>\n H56mError.make({ message: `${message}: ${String(cause)}` });\n","import { loadAddon } from \"@masseater.dev/lint-host\";\nimport { Predicate } from \"effect\";\nimport type { Effect } from \"effect\";\n\nimport type { H56mConfig } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { H56mError } from \"#/shared/lib/errors.ts\";\n\nexport interface DetectorInput {\n readonly config: Omit<H56mConfig, \"ignoredSecrets\">;\n readonly ignored: readonly string[];\n readonly traceparent?: string;\n}\n\nexport interface TextInput {\n readonly path: string;\n readonly text: string;\n readonly traceparent?: string;\n}\n\nexport interface GitInput {\n readonly root: string;\n readonly source: unknown;\n readonly traceparent?: string;\n}\n\nexport interface NativeDetector {\n readonly scan: (input: TextInput) => unknown;\n readonly scanGit: (input: GitInput) => unknown;\n}\n\nexport interface Native {\n readonly SecretDetector: new (input: DetectorInput) => NativeDetector;\n readonly flushTelemetry: () => Promise<void>;\n}\n\nconst isNative = (value: unknown): value is Native =>\n Predicate.hasProperty(value, \"SecretDetector\") &&\n Predicate.isFunction(value.SecretDetector) &&\n Predicate.hasProperty(value, \"flushTelemetry\") &&\n Predicate.isFunction(value.flushTelemetry);\n\nexport const native: Effect.Effect<Native, H56mError> = loadAddon({\n packageName: \"@r_masseater/h56m\",\n binary: \"h56m\",\n from: import.meta.url,\n isAddon: isNative,\n failWith: failedWith,\n});\n","import { callAddon, traceparent } from \"@masseater.dev/lint-host\";\nimport { Effect, Option, Schema } from \"effect\";\n\nimport { FindingSchema } from \"#/shared/config/index.ts\";\nimport type { Finding, GitSource, H56mConfig } from \"#/shared/config/index.ts\";\nimport { failedWith } from \"#/shared/lib/errors.ts\";\nimport type { H56mError } from \"#/shared/lib/errors.ts\";\nimport { native } from \"#/shared/native/index.ts\";\nimport type { NativeDetector } from \"#/shared/native/index.ts\";\n\nconst ONE_FILE = 1;\nconst WHOLE_REPOSITORY = 0;\n\nconst decodeFindings = Schema.decodeUnknownEffect(Schema.Array(FindingSchema));\n\nexport interface TextScan {\n readonly path: string;\n readonly text: string;\n}\n\nexport interface GitScan {\n readonly root: string;\n readonly source: GitSource;\n}\n\nexport interface Detector {\n readonly scanText: (scan: TextScan) => Effect.Effect<readonly Finding[], H56mError>;\n readonly scanGit: (scan: GitScan) => Effect.Effect<readonly Finding[], H56mError>;\n}\n\ntype Traced<Input> = Input | (Input & { readonly traceparent: string });\n\nconst withParent = <Input extends object>(input: Input): Effect.Effect<Traced<Input>> =>\n traceparent.pipe(\n Effect.map(\n Option.match({\n onNone: (): Traced<Input> => input,\n onSome: (value): Traced<Input> => ({ ...input, traceparent: value }),\n }),\n ),\n );\n\ninterface NativeScan {\n readonly name: string;\n readonly files: number;\n readonly call: () => unknown;\n}\n\nconst run = ({ name, files, call }: NativeScan): Effect.Effect<readonly Finding[], H56mError> =>\n callAddon({ addon: native, name, files, call, failWith: failedWith }).pipe(\n Effect.flatMap((found) =>\n decodeFindings(found).pipe(Effect.mapError(failedWith(\"h56m returned an unknown shape\"))),\n ),\n );\n\nconst scannerOf = (detector: NativeDetector): Detector => ({\n scanText: (scan) =>\n withParent(scan).pipe(\n Effect.flatMap((input) =>\n run({ name: \"h56m.text\", files: ONE_FILE, call: () => detector.scan(input) }),\n ),\n Effect.withSpan(\"h56m.scan_text\"),\n ),\n scanGit: (scan) =>\n withParent(scan).pipe(\n Effect.flatMap((input) =>\n run({ name: \"h56m.git\", files: WHOLE_REPOSITORY, call: () => detector.scanGit(input) }),\n ),\n Effect.withSpan(\"h56m.scan_git\", { attributes: { \"h56m.source\": scan.source.type } }),\n ),\n});\n\nexport const makeDetector = Effect.fn(\"h56m.detector\")(function* makeDetector(\n config: H56mConfig = {},\n) {\n const { ignoredSecrets = [], ...rest } = config;\n const input = yield* withParent({ config: rest, ignored: ignoredSecrets });\n const detector = yield* callAddon({\n addon: native,\n name: \"h56m\",\n files: WHOLE_REPOSITORY,\n call: (addon) => new addon.SecretDetector(input),\n failWith: failedWith,\n });\n return scannerOf(detector);\n});\n","import { Option, String as Str, pipe } from \"effect\";\n\nimport type { Finding } from \"#/shared/config/index.ts\";\n\nconst START = 0;\nconst SHORT_COMMIT = 12;\n\nconst commitOf = (finding: Finding): string =>\n pipe(\n Option.fromNullishOr(finding.commit),\n Option.map((commit) => ` (${Str.slice(START, SHORT_COMMIT)(commit)})`),\n Option.getOrElse(() => \"\"),\n );\n\nexport const format = (finding: Finding): string =>\n `${finding.path}:${String(finding.line)}:${String(finding.column)} ${finding.rule} ${finding.description} sha256:${finding.digest}${commitOf(finding)}`;\n","import { Option, Predicate, pipe } from \"effect\";\n\nimport type { H56mConfig } from \"#/shared/config/index.ts\";\n\nconst hasSection = (value: unknown): value is { readonly h56m: H56mConfig } =>\n Predicate.hasProperty(value, \"h56m\") && Predicate.isObject(value.h56m);\n\nexport const h56mSection = (config: unknown): H56mConfig =>\n pipe(\n Option.liftPredicate(config, hasSection),\n Option.map((value) => value.h56m),\n Option.getOrElse((): H56mConfig => ({})),\n );\n"],"mappings":";;;;;;;;;AAEA,MAAM,SAAS,aACb,MAAM,MAAM,QAAQ,CAAC,CAAC,KACpB,MAAM,KAAK,eAAe,MAAM,GAChC,MAAM,KAAK,eAAe,OAAO,GACjC,MAAM,aAAa,EAAE,CACvB;AAEF,MAAa,iBAAiB,GAAG,QAAQ,SAAS,GAAG,QAAQ,OAAO,MAAM,QAAQ,QAAQ;AAE1F,MAAa,eAAe,WAA2B,GAAG,OAAO,GAAG,eAAe;;ACJnF,MAAMA,gBAAc,OAAO;AAE3B,IAAM,mBAAN,cAA+BA,cAAiE,CAAC,CAC/F,oBACA,EAAE,SAAS,OAAO,OAAO,CAC3B,CAAC,CAAC,CAAC;AAEH,MAAM,UAA8D;CAClE,QAAQ,SAAS,MAAM,KAAK;CAC5B,SAAS,SAAS,MAAM,KAAK;CAC7B,QAAQ,SAAS,GAAG,KAAK;AAC3B;AAEA,MAAM,UAAU;AAShB,MAAM,QAAQ,OAAO,GAAG,OAAO,CAAC,CAAC,UAAU,MAAM,OAAe,WAAmB;CAEjF,MAAM,WAAW,QAAO,OADD,oBAAoB,oBAAA,CACX,SAC9B,aAAa,KAAK,SAAS;EAAC;EAAS;EAAa;EAAY;EAAM;CAAK,GAAG;EAC1E,KAAK;EACL,QAAQ;EACR,QAAQ;CACV,CAAC,CACH;CACA,MAAM,UAAU,iBAAiB,KAAK,EAAE,SAAS,qBAAqB,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G,QAAQ,KAAK,GAAG,QAAQ,YAAY,UAAU,QAAQ,SAAS,SAAS,OAAO;;ACXtJ,MAAM,cAAc,UAClB,UAAU,YAAY,OAAO,MAAM,KAAK,UAAU,SAAS,MAAM,IAAI;AAEvE,MAAa,eAAe,WAC1B,KACE,OAAO,cAAc,QAAQ,UAAU,GACvC,OAAO,KAAK,UAAU,MAAM,IAAI,GAChC,OAAO,iBAA6B,CAAC,EAAE,CACzC"}
|
package/dist/vite.d.mts
ADDED
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@r_masseater/h56m",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A secret scanner engine written in Rust that scans git history, the staged changes or any text with Betterleaks-format rules from a preset, configured from vite.config.ts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"betterleaks",
|
|
7
|
+
"gitleaks",
|
|
8
|
+
"secrets",
|
|
9
|
+
"security",
|
|
10
|
+
"tanstack-intent",
|
|
11
|
+
"vite-plus"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/masseater/masseater.dev/tree/main/libs/h56m#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/masseater/masseater.dev/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT AND Apache-2.0 AND CC-BY-SA-4.0",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/masseater/masseater.dev.git",
|
|
21
|
+
"directory": "libs/h56m"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"h56m": "./dist/cli.mjs"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"LICENSE",
|
|
28
|
+
"THIRD-PARTY-NOTICES.txt",
|
|
29
|
+
"dist",
|
|
30
|
+
"skills/scan-secrets"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"imports": {
|
|
34
|
+
"#/*": "./src/*"
|
|
35
|
+
},
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.mts",
|
|
39
|
+
"default": "./dist/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"./vite": {
|
|
42
|
+
"types": "./dist/vite.d.mts",
|
|
43
|
+
"default": "./dist/vite.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public",
|
|
49
|
+
"provenance": true
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@effect/platform-node": "^4.1.4"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@effect/vitest": "4.1.4",
|
|
56
|
+
"@masseater.dev/lint-host": "0.0.0",
|
|
57
|
+
"@r_masseater/vitest-otlp": "0.2.0",
|
|
58
|
+
"@types/node": "26.6.6",
|
|
59
|
+
"effect": "4.1.4",
|
|
60
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@8.3.8000",
|
|
61
|
+
"vite-plus": "1.7.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"effect": "^4.1.2",
|
|
65
|
+
"vite": "*",
|
|
66
|
+
"vite-plus": ">=1.5.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"vite": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"vite-plus": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=26"
|
|
78
|
+
},
|
|
79
|
+
"native": {
|
|
80
|
+
"binary": "h56m",
|
|
81
|
+
"targets": [
|
|
82
|
+
"linux-x64-gnu",
|
|
83
|
+
"win32-x64-msvc"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"optionalDependencies": {
|
|
87
|
+
"@r_masseater/h56m-linux-x64-gnu": "0.1.0",
|
|
88
|
+
"@r_masseater/h56m-win32-x64-msvc": "0.1.0"
|
|
89
|
+
},
|
|
90
|
+
"scripts": {}
|
|
91
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scan-secrets
|
|
3
|
+
description: >
|
|
4
|
+
Use when setting up @r_masseater/h56m in vite.config.ts, scanning commits, staged changes or
|
|
5
|
+
text for leaked secrets, writing a custom secret rule or filter, or silencing a finding that is
|
|
6
|
+
not a secret. Covers extending a preset, the Betterleaks-format settings, ignoredSecrets, h56m:allow, the CLI and
|
|
7
|
+
makeDetector.
|
|
8
|
+
metadata:
|
|
9
|
+
type: core
|
|
10
|
+
library: "@r_masseater/h56m"
|
|
11
|
+
library_version: 0.1.0
|
|
12
|
+
sources:
|
|
13
|
+
- src/app/index.ts
|
|
14
|
+
- src/shared/config/types.ts
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# scan-secrets
|
|
18
|
+
|
|
19
|
+
h56m finds secrets with the Kingfisher engine. It has no rules of its own, so extend a preset from
|
|
20
|
+
`@r_masseater/h56m-presets` or a TOML file of your own. It never sends a secret anywhere to check
|
|
21
|
+
whether it is live.
|
|
22
|
+
|
|
23
|
+
## Setup
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
vp add -D @r_masseater/h56m @r_masseater/h56m-presets
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import "@r_masseater/h56m/vite";
|
|
31
|
+
import { betterleaks } from "@r_masseater/h56m-presets";
|
|
32
|
+
import { defineConfig } from "vite-plus";
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
h56m: {
|
|
36
|
+
extend: { path: betterleaks, disabledRules: ["generic-api-key"] },
|
|
37
|
+
filter:
|
|
38
|
+
'matchesAny(finding.line, [`EXAMPLE_KEY`]) || matchesAny(attributes["path"], [`^fixtures/`])',
|
|
39
|
+
rules: [{ id: "my-token", regex: "\\b(my_[A-Za-z0-9]{20})\\b", keywords: ["my_"] }],
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The settings use the Betterleaks format. `extend.path` names the preset file and
|
|
45
|
+
`disabledRules` turns off rules of it. Without `extend`, only `rules` run. `extend.useDefault` is
|
|
46
|
+
rejected. `filter` on the top level or on a rule is an
|
|
47
|
+
Expr expression that drops a finding when it is true. It sees `finding` (`secret`, `line`, ...)
|
|
48
|
+
and `attributes["path"]`, and has `matchesAny`, `entropy` and the other Betterleaks helpers.
|
|
49
|
+
|
|
50
|
+
## CLI
|
|
51
|
+
|
|
52
|
+
`h56m` scans the commits after the first of the given revisions, or after `origin/HEAD`,
|
|
53
|
+
`origin/main` or `origin/master`, and scans the whole history when none resolves.
|
|
54
|
+
`h56m --staged` scans the index only. Each finding is printed as
|
|
55
|
+
`path:line:column rule description sha256:<digest> (commit)`, without the secret, and the exit code
|
|
56
|
+
is 1 when anything is found.
|
|
57
|
+
|
|
58
|
+
## Silencing a finding
|
|
59
|
+
|
|
60
|
+
Fix a real secret by removing it and rotating it. For a value that is not a secret, prefer these
|
|
61
|
+
in order:
|
|
62
|
+
|
|
63
|
+
- Add `h56m:allow` on the same line.
|
|
64
|
+
- Add the digest the CLI printed to `ignoredSecrets`.
|
|
65
|
+
- Match the line or the path in `filter`.
|
|
66
|
+
|
|
67
|
+
## From code
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { makeDetector } from "@r_masseater/h56m";
|
|
71
|
+
|
|
72
|
+
const program = Effect.gen(function* () {
|
|
73
|
+
const detector = yield* makeDetector({ extend: { path: betterleaks } });
|
|
74
|
+
const inText = yield* detector.scanText({ path: "chat.md", text });
|
|
75
|
+
const staged = yield* detector.scanGit({ root, source: { type: "staged" } });
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`scanGit` takes `{ type: "history", bases, head }`, which scans the commits after the first of `bases`
|
|
80
|
+
that names a commit, `{ type: "staged" }` or
|
|
81
|
+
`{ type: "snapshot", revision }`. A finding has `rule`, `confidence`, 1-based `line` and `column`
|
|
82
|
+
in UTF-16 code units, `secret`, its SHA-256 `digest`, and `commit` for history scans. Errors are
|
|
83
|
+
`H56mError`.
|