@r_masseater/h56m 0.1.0 → 0.3.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.
@@ -16,19 +16,19 @@ sources:
16
16
 
17
17
  # scan-secrets
18
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
19
+ h56m finds secrets with its own engine, which follows Betterleaks. 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
21
  whether it is live.
22
22
 
23
23
  ## Setup
24
24
 
25
25
  ```sh
26
- vp add -D @r_masseater/h56m @r_masseater/h56m-presets
26
+ vp add -D @r_masseater/h56m
27
27
  ```
28
28
 
29
29
  ```ts
30
30
  import "@r_masseater/h56m/vite";
31
- import { betterleaks } from "@r_masseater/h56m-presets";
31
+ import { betterleaks } from "@r_masseater/h56m/presets";
32
32
  import { defineConfig } from "vite-plus";
33
33
 
34
34
  export default defineConfig({
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: use-h56m-presets
3
+ description: >
4
+ Use when choosing the rules h56m scans with, or when h56m reports that it has no rules. Covers
5
+ extending a preset from @r_masseater/h56m/presets in vite.config.ts or makeDetector, and turning
6
+ off single rules of a preset.
7
+ metadata:
8
+ type: core
9
+ library: "@r_masseater/h56m"
10
+ library_version: 0.1.0
11
+ sources:
12
+ - src/app/presets.ts
13
+ ---
14
+
15
+ # use-h56m-presets
16
+
17
+ h56m holds only the engine. The rules come from a preset file that `extend.path` names, plus the
18
+ `rules` a project adds.
19
+
20
+ ## Setup
21
+
22
+ ```sh
23
+ vp add -D @r_masseater/h56m
24
+ ```
25
+
26
+ ```ts
27
+ import "@r_masseater/h56m/vite";
28
+ import { betterleaks } from "@r_masseater/h56m/presets";
29
+ import { defineConfig } from "vite-plus";
30
+
31
+ export default defineConfig({
32
+ h56m: { extend: { path: betterleaks, disabledRules: ["generic-api-key"] } },
33
+ });
34
+ ```
35
+
36
+ `betterleaks` is the default Betterleaks configuration. Pass the same `extend` to `makeDetector`
37
+ when scanning from code.
38
+
39
+ ## Rules
40
+
41
+ - Do not set `extend.useDefault`. h56m rejects it, because the engine carries no rules.
42
+ - Turn off a rule with `disabledRules` instead of copying the preset and editing it.
43
+ - A preset file is a Betterleaks TOML file, so a project can also point `extend.path` at its own
44
+ file, which may extend a preset in turn.
@@ -1 +0,0 @@
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,OAA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