@intentius/chant-lexicon-docker 0.124.97 → 0.124.99
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/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/generate-cli.d.ts +0 -1
- package/dist/codegen/generate-compose.d.ts +0 -1
- package/dist/codegen/generate-dockerfile.d.ts +0 -1
- package/dist/codegen/generate.d.ts +0 -1
- package/dist/codegen/naming.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/codegen/patches.d.ts +0 -1
- package/dist/codegen/versions.d.ts +0 -1
- package/dist/compose-key.d.ts +0 -1
- package/dist/composites/catalog.d.ts +0 -1
- package/dist/composites/docker-otel-collector.d.ts +0 -1
- package/dist/composites/docker-web-service.d.ts +0 -1
- package/dist/composites/index.d.ts +0 -1
- package/dist/coverage.d.ts +0 -1
- package/dist/default-labels.d.ts +0 -1
- package/dist/detect.d.ts +0 -1
- package/dist/dockerfile-order.d.ts +0 -1
- package/dist/export-resources.d.ts +0 -1
- package/dist/generated/index.d.ts +0 -1
- package/dist/generated/runtime.d.ts +0 -1
- package/dist/import/adapter.d.ts +0 -1
- package/dist/import/adapter.js +4 -2
- package/dist/import/embedded.d.ts +0 -1
- package/dist/import/engine.d.ts +0 -1
- package/dist/import/generator.d.ts +9 -2
- package/dist/import/generator.js +23 -1
- package/dist/import/live-export.d.ts +0 -1
- package/dist/import/parser.d.ts +0 -1
- package/dist/import/testdata/tar.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/interpolation.d.ts +0 -1
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/audit-lineage.d.ts +0 -1
- package/dist/lint/post-synth/add-url-checksum.d.ts +0 -1
- package/dist/lint/post-synth/apt-no-recommends.d.ts +0 -1
- package/dist/lint/post-synth/apt-update-alone.d.ts +0 -1
- package/dist/lint/post-synth/cache-busting-copy.d.ts +0 -1
- package/dist/lint/post-synth/copy-from-stage.d.ts +0 -1
- package/dist/lint/post-synth/docker-helpers.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/no-latest-image.d.ts +0 -1
- package/dist/lint/post-synth/no-root-user.d.ts +0 -1
- package/dist/lint/post-synth/prefer-copy.d.ts +0 -1
- package/dist/lint/post-synth/relative-workdir.d.ts +0 -1
- package/dist/lint/post-synth/repeated-cmd.d.ts +0 -1
- package/dist/lint/post-synth/root-after-user.d.ts +0 -1
- package/dist/lint/post-synth/ssh-port-exposed.d.ts +0 -1
- package/dist/lint/post-synth/unused-global-arg.d.ts +0 -1
- package/dist/lint/post-synth/unused-volume.d.ts +0 -1
- package/dist/lint/rules/data/deprecated-images.d.ts +0 -1
- package/dist/lint/rules/data/known-base-images.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/no-latest-tag.d.ts +0 -1
- package/dist/lint/rules/per-kind-order.d.ts +0 -1
- package/dist/list-artifacts.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/spec/fetch-compose.d.ts +0 -1
- package/dist/spec/fetch-engine.d.ts +0 -1
- package/dist/spec/parse-compose.d.ts +0 -1
- package/dist/spec/parse-engine.d.ts +0 -1
- package/dist/validate-cli.d.ts +0 -1
- package/dist/validate.d.ts +0 -1
- package/dist/variables.d.ts +0 -1
- package/package.json +4 -5
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/generate-cli.d.ts.map +0 -1
- package/dist/codegen/generate-compose.d.ts.map +0 -1
- package/dist/codegen/generate-dockerfile.d.ts.map +0 -1
- package/dist/codegen/generate.d.ts.map +0 -1
- package/dist/codegen/naming.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/codegen/patches.d.ts.map +0 -1
- package/dist/codegen/versions.d.ts.map +0 -1
- package/dist/compose-key.d.ts.map +0 -1
- package/dist/composites/catalog.d.ts.map +0 -1
- package/dist/composites/docker-otel-collector.d.ts.map +0 -1
- package/dist/composites/docker-web-service.d.ts.map +0 -1
- package/dist/composites/index.d.ts.map +0 -1
- package/dist/coverage.d.ts.map +0 -1
- package/dist/default-labels.d.ts.map +0 -1
- package/dist/detect.d.ts.map +0 -1
- package/dist/dockerfile-order.d.ts.map +0 -1
- package/dist/export-resources.d.ts.map +0 -1
- package/dist/generated/index.d.ts.map +0 -1
- package/dist/generated/runtime.d.ts.map +0 -1
- package/dist/import/adapter.d.ts.map +0 -1
- package/dist/import/embedded.d.ts.map +0 -1
- package/dist/import/engine.d.ts.map +0 -1
- package/dist/import/generator.d.ts.map +0 -1
- package/dist/import/live-export.d.ts.map +0 -1
- package/dist/import/parser.d.ts.map +0 -1
- package/dist/import/testdata/tar.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interpolation.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/audit-lineage.d.ts.map +0 -1
- package/dist/lint/post-synth/add-url-checksum.d.ts.map +0 -1
- package/dist/lint/post-synth/apt-no-recommends.d.ts.map +0 -1
- package/dist/lint/post-synth/apt-update-alone.d.ts.map +0 -1
- package/dist/lint/post-synth/cache-busting-copy.d.ts.map +0 -1
- package/dist/lint/post-synth/copy-from-stage.d.ts.map +0 -1
- package/dist/lint/post-synth/docker-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/no-latest-image.d.ts.map +0 -1
- package/dist/lint/post-synth/no-root-user.d.ts.map +0 -1
- package/dist/lint/post-synth/prefer-copy.d.ts.map +0 -1
- package/dist/lint/post-synth/relative-workdir.d.ts.map +0 -1
- package/dist/lint/post-synth/repeated-cmd.d.ts.map +0 -1
- package/dist/lint/post-synth/root-after-user.d.ts.map +0 -1
- package/dist/lint/post-synth/ssh-port-exposed.d.ts.map +0 -1
- package/dist/lint/post-synth/unused-global-arg.d.ts.map +0 -1
- package/dist/lint/post-synth/unused-volume.d.ts.map +0 -1
- package/dist/lint/rules/data/deprecated-images.d.ts.map +0 -1
- package/dist/lint/rules/data/known-base-images.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/no-latest-tag.d.ts.map +0 -1
- package/dist/lint/rules/per-kind-order.d.ts.map +0 -1
- package/dist/list-artifacts.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/spec/fetch-compose.d.ts.map +0 -1
- package/dist/spec/fetch-engine.d.ts.map +0 -1
- package/dist/spec/parse-compose.d.ts.map +0 -1
- package/dist/spec/parse-engine.d.ts.map +0 -1
- package/dist/validate-cli.d.ts.map +0 -1
- package/dist/validate.d.ts.map +0 -1
- package/dist/variables.d.ts.map +0 -1
- package/src/codegen/__snapshots__/okf.test.ts.snap +0 -555
- package/src/codegen/docs-cli.ts +0 -10
- package/src/codegen/docs.ts +0 -171
- package/src/codegen/generate-cli.ts +0 -36
- package/src/codegen/generate-compose.ts +0 -21
- package/src/codegen/generate-dockerfile.ts +0 -21
- package/src/codegen/generate.test.ts +0 -115
- package/src/codegen/generate.ts +0 -258
- package/src/codegen/naming.test.ts +0 -81
- package/src/codegen/naming.ts +0 -54
- package/src/codegen/okf.test.ts +0 -36
- package/src/codegen/package.ts +0 -59
- package/src/codegen/patches.ts +0 -42
- package/src/codegen/versions.ts +0 -46
- package/src/compose-key.ts +0 -31
- package/src/composites/catalog.test.ts +0 -39
- package/src/composites/catalog.ts +0 -118
- package/src/composites/docker-otel-collector.ts +0 -83
- package/src/composites/docker-web-service.test.ts +0 -34
- package/src/composites/docker-web-service.ts +0 -75
- package/src/composites/index.ts +0 -9
- package/src/coverage.test.ts +0 -33
- package/src/coverage.ts +0 -54
- package/src/default-labels.test.ts +0 -85
- package/src/default-labels.ts +0 -72
- package/src/detect.ts +0 -7
- package/src/dockerfile-order.ts +0 -20
- package/src/docs-examples.test.ts +0 -141
- package/src/export-resources.ts +0 -90
- package/src/generated/index.d.ts +0 -407
- package/src/generated/index.ts +0 -410
- package/src/generated/runtime.ts +0 -4
- package/src/import/adapter.ts +0 -99
- package/src/import/embedded-live.test.ts +0 -248
- package/src/import/embedded.ts +0 -83
- package/src/import/engine.ts +0 -107
- package/src/import/generator.test.ts +0 -134
- package/src/import/generator.ts +0 -202
- package/src/import/live-export.test.ts +0 -271
- package/src/import/live-export.ts +0 -359
- package/src/import/parser.test.ts +0 -137
- package/src/import/parser.ts +0 -269
- package/src/import/roundtrip.test.ts +0 -257
- package/src/import/testdata/configs-secrets.yaml +0 -15
- package/src/import/testdata/full.yaml +0 -43
- package/src/import/testdata/names-and-fields.yaml +0 -44
- package/src/import/testdata/simple.yaml +0 -9
- package/src/import/testdata/tar.ts +0 -24
- package/src/import/testdata/webapp.yaml +0 -41
- package/src/index.ts +0 -32
- package/src/interpolation.test.ts +0 -41
- package/src/interpolation.ts +0 -76
- package/src/lint/audit-catalog.ts +0 -28
- package/src/lint/audit-lineage.ts +0 -48
- package/src/lint/post-synth/add-url-checksum.ts +0 -38
- package/src/lint/post-synth/apt-no-recommends.ts +0 -43
- package/src/lint/post-synth/apt-update-alone.ts +0 -39
- package/src/lint/post-synth/cache-busting-copy.ts +0 -65
- package/src/lint/post-synth/copy-from-stage.ts +0 -54
- package/src/lint/post-synth/docker-helpers.ts +0 -194
- package/src/lint/post-synth/index.ts +0 -33
- package/src/lint/post-synth/no-latest-image.ts +0 -36
- package/src/lint/post-synth/no-root-user.ts +0 -38
- package/src/lint/post-synth/post-synth.test.ts +0 -330
- package/src/lint/post-synth/prefer-copy.ts +0 -53
- package/src/lint/post-synth/relative-workdir.ts +0 -38
- package/src/lint/post-synth/repeated-cmd.ts +0 -35
- package/src/lint/post-synth/root-after-user.ts +0 -44
- package/src/lint/post-synth/ssh-port-exposed.ts +0 -68
- package/src/lint/post-synth/unused-global-arg.ts +0 -38
- package/src/lint/post-synth/unused-volume.ts +0 -49
- package/src/lint/rules/data/deprecated-images.ts +0 -28
- package/src/lint/rules/data/known-base-images.ts +0 -20
- package/src/lint/rules/index.ts +0 -6
- package/src/lint/rules/no-latest-tag.ts +0 -63
- package/src/lint/rules/per-kind-order.ts +0 -130
- package/src/lint/rules/rules.test.ts +0 -170
- package/src/list-artifacts.test.ts +0 -141
- package/src/list-artifacts.ts +0 -164
- package/src/lsp/completions.test.ts +0 -40
- package/src/lsp/completions.ts +0 -21
- package/src/lsp/hover.test.ts +0 -35
- package/src/lsp/hover.ts +0 -39
- package/src/package-cli.ts +0 -25
- package/src/plugin.test.ts +0 -121
- package/src/plugin.ts +0 -268
- package/src/serializer.test.ts +0 -545
- package/src/serializer.ts +0 -444
- package/src/skills/chant-docker-patterns.md +0 -222
- package/src/skills/chant-docker.md +0 -156
- package/src/spec/fetch-compose.ts +0 -35
- package/src/spec/fetch-engine.ts +0 -25
- package/src/spec/parse-compose.ts +0 -195
- package/src/spec/parse-engine.ts +0 -59
- package/src/typecheck.e2e.test.ts +0 -125
- package/src/typed-props.test.ts +0 -60
- package/src/validate-cli.ts +0 -19
- package/src/validate.test.ts +0 -16
- package/src/validate.ts +0 -44
- package/src/variables.test.ts +0 -32
- package/src/variables.ts +0 -47
- /package/{src → dist}/generated/lexicon-docker.json +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
api:
|
|
3
|
-
image: node:20-alpine
|
|
4
|
-
ports:
|
|
5
|
-
- "3000:3000"
|
|
6
|
-
environment:
|
|
7
|
-
NODE_ENV: production
|
|
8
|
-
PORT: "3000"
|
|
9
|
-
depends_on:
|
|
10
|
-
- db
|
|
11
|
-
- cache
|
|
12
|
-
restart: unless-stopped
|
|
13
|
-
healthcheck:
|
|
14
|
-
test:
|
|
15
|
-
- CMD
|
|
16
|
-
- curl
|
|
17
|
-
- -f
|
|
18
|
-
- http://localhost:3000/health
|
|
19
|
-
interval: 30s
|
|
20
|
-
timeout: 10s
|
|
21
|
-
retries: 3
|
|
22
|
-
volumes:
|
|
23
|
-
- "app-data:/data"
|
|
24
|
-
|
|
25
|
-
db:
|
|
26
|
-
image: postgres:16-alpine
|
|
27
|
-
environment:
|
|
28
|
-
POSTGRES_DB: appdb
|
|
29
|
-
POSTGRES_USER: app
|
|
30
|
-
POSTGRES_PASSWORD: secret
|
|
31
|
-
volumes:
|
|
32
|
-
- "pg-data:/var/lib/postgresql/data"
|
|
33
|
-
|
|
34
|
-
cache:
|
|
35
|
-
image: redis:7-alpine
|
|
36
|
-
restart: always
|
|
37
|
-
|
|
38
|
-
volumes:
|
|
39
|
-
app-data:
|
|
40
|
-
pg-data:
|
|
41
|
-
driver: local
|
package/src/index.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Serializer
|
|
2
|
-
export { dockerSerializer } from "./serializer";
|
|
3
|
-
|
|
4
|
-
// Plugin
|
|
5
|
-
export { dockerPlugin } from "./plugin";
|
|
6
|
-
|
|
7
|
-
// Interpolation intrinsic
|
|
8
|
-
export { env } from "./interpolation";
|
|
9
|
-
export type { EnvOptions, EnvIntrinsic } from "./interpolation";
|
|
10
|
-
|
|
11
|
-
// Context variables
|
|
12
|
-
export { DOCKER_VARS, COMPOSE_VARS } from "./variables";
|
|
13
|
-
export type { DockerVar, ComposeVar } from "./variables";
|
|
14
|
-
|
|
15
|
-
// Default labels
|
|
16
|
-
export { defaultLabels, defaultAnnotations, isDefaultLabels, isDefaultAnnotations } from "./default-labels";
|
|
17
|
-
export { DEFAULT_LABELS_MARKER, DEFAULT_ANNOTATIONS_MARKER } from "./default-labels";
|
|
18
|
-
export type { DefaultLabels, DefaultAnnotations } from "./default-labels";
|
|
19
|
-
|
|
20
|
-
// Compose keys that are not identifiers (#3937)
|
|
21
|
-
export { composeKey, getComposeKey, COMPOSE_KEY } from "./compose-key";
|
|
22
|
-
|
|
23
|
-
// Generated entities — populated by `npm run generate`
|
|
24
|
-
export * from "./generated/index";
|
|
25
|
-
|
|
26
|
-
// Composites
|
|
27
|
-
export * from "./composites/index";
|
|
28
|
-
|
|
29
|
-
// Codegen pipeline (for external tooling)
|
|
30
|
-
export { generate, writeGeneratedFiles } from "./codegen/generate";
|
|
31
|
-
export { packageLexicon } from "./codegen/package";
|
|
32
|
-
export type { PackageOptions, PackageResult } from "./codegen/package";
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "vitest";
|
|
2
|
-
import { env } from "./interpolation";
|
|
3
|
-
import { INTRINSIC_MARKER } from "@intentius/chant/intrinsic";
|
|
4
|
-
|
|
5
|
-
describe("env()", () => {
|
|
6
|
-
test("bare variable: ${VAR}", () => {
|
|
7
|
-
const e = env("APP_IMAGE");
|
|
8
|
-
expect(e.toJSON()).toBe("${APP_IMAGE}");
|
|
9
|
-
expect(e.toString()).toBe("${APP_IMAGE}");
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("default value: ${VAR:-default}", () => {
|
|
13
|
-
const e = env("APP_IMAGE", { default: "myapp:latest" });
|
|
14
|
-
expect(e.toJSON()).toBe("${APP_IMAGE:-myapp:latest}");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("required variable: ${VAR:?error}", () => {
|
|
18
|
-
const e = env("DB_URL", { required: true });
|
|
19
|
-
expect(e.toJSON()).toBe("${DB_URL:?DB_URL is required}");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("required with custom error message: ${VAR:?msg}", () => {
|
|
23
|
-
const e = env("DB_URL", { errorMessage: "Database URL must be set" });
|
|
24
|
-
expect(e.toJSON()).toBe("${DB_URL:?Database URL must be set}");
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("ifSet: ${VAR:+value}", () => {
|
|
28
|
-
const e = env("DEBUG", { ifSet: "true" });
|
|
29
|
-
expect(e.toJSON()).toBe("${DEBUG:+true}");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("ifSet takes precedence over default", () => {
|
|
33
|
-
const e = env("X", { ifSet: "on", default: "off" });
|
|
34
|
-
expect(e.toJSON()).toBe("${X:+on}");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("has INTRINSIC_MARKER", () => {
|
|
38
|
-
const e = env("FOO");
|
|
39
|
-
expect(INTRINSIC_MARKER in e).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
});
|
package/src/interpolation.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Docker Compose variable interpolation intrinsics.
|
|
3
|
-
*
|
|
4
|
-
* Docker Compose supports:
|
|
5
|
-
* ${VAR} — required variable (fails if unset)
|
|
6
|
-
* ${VAR:-default} — use default if VAR is unset or empty
|
|
7
|
-
* ${VAR:?error} — fail with error message if VAR is unset or empty
|
|
8
|
-
* ${VAR:+value} — use value if VAR is set
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* import { env } from "@intentius/chant-lexicon-docker";
|
|
12
|
-
*
|
|
13
|
-
* export const api = new Service({
|
|
14
|
-
* image: env("APP_IMAGE", { default: "myapp:latest" }),
|
|
15
|
-
* environment: {
|
|
16
|
-
* DB_URL: env("DB_URL", { required: true }),
|
|
17
|
-
* },
|
|
18
|
-
* });
|
|
19
|
-
*
|
|
20
|
-
* // Serializes to:
|
|
21
|
-
* // services:
|
|
22
|
-
* // api:
|
|
23
|
-
* // image: ${APP_IMAGE:-myapp:latest}
|
|
24
|
-
* // environment:
|
|
25
|
-
* // DB_URL: ${DB_URL:?DB_URL is required}
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
import { INTRINSIC_MARKER } from "@intentius/chant/intrinsic";
|
|
29
|
-
|
|
30
|
-
export interface EnvOptions {
|
|
31
|
-
/** Default value if VAR is unset or empty: ${VAR:-default} */
|
|
32
|
-
default?: string;
|
|
33
|
-
/** If true and no default, emit ${VAR:?VAR is required}: fail on missing */
|
|
34
|
-
required?: boolean;
|
|
35
|
-
/** Error message for required variables: ${VAR:?errorMessage} */
|
|
36
|
-
errorMessage?: string;
|
|
37
|
-
/** Alternate value when VAR is set: ${VAR:+value} */
|
|
38
|
-
ifSet?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface EnvIntrinsic {
|
|
42
|
-
readonly [INTRINSIC_MARKER]: true;
|
|
43
|
-
/** Emit the Docker Compose interpolation string */
|
|
44
|
-
toJSON(): string;
|
|
45
|
-
toString(): string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Create a Docker Compose variable interpolation intrinsic.
|
|
50
|
-
*
|
|
51
|
-
* @param name - Environment variable name
|
|
52
|
-
* @param opts - Interpolation options
|
|
53
|
-
*/
|
|
54
|
-
export function env(name: string, opts: EnvOptions = {}): EnvIntrinsic {
|
|
55
|
-
function interpolationString(): string {
|
|
56
|
-
if (opts.ifSet !== undefined) {
|
|
57
|
-
return `\${${name}:+${opts.ifSet}}`;
|
|
58
|
-
}
|
|
59
|
-
if (opts.default !== undefined) {
|
|
60
|
-
return `\${${name}:-${opts.default}}`;
|
|
61
|
-
}
|
|
62
|
-
if (opts.required || opts.errorMessage) {
|
|
63
|
-
const msg = opts.errorMessage ?? `${name} is required`;
|
|
64
|
-
return `\${${name}:?${msg}}`;
|
|
65
|
-
}
|
|
66
|
-
return `\${${name}}`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const value = interpolationString();
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
[INTRINSIC_MARKER]: true,
|
|
73
|
-
toJSON: () => value,
|
|
74
|
-
toString: () => value,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The docker lexicon's `chant audit` catalog — metadata for the DKRD*
|
|
3
|
-
* Dockerfile/Compose post-synth rules. Contributed via `dockerPlugin.auditCatalog()` (#687).
|
|
4
|
-
*/
|
|
5
|
-
import { auditRule, SCORECARD_PINNED, type RuleMeta, type Authority, applyLineage } from "@intentius/chant/audit/catalog";
|
|
6
|
-
import { dockerAuditLineage } from "./audit-lineage";
|
|
7
|
-
|
|
8
|
-
const DOCKER_SEC: Authority = { name: "Docker — Security best practices", url: "https://docs.docker.com/develop/security-best-practices/" };
|
|
9
|
-
|
|
10
|
-
export const dockerAuditCatalog: Record<string, RuleMeta> = {
|
|
11
|
-
DKRD001: auditRule("DKRD001", "merge-worthy", "guidance", "Service uses :latest or untagged image", "Pin the image to an explicit version tag (ideally a digest).", { authority: [SCORECARD_PINNED] }),
|
|
12
|
-
DKRD002: auditRule("DKRD002", "report-only", "guidance", "Named volume declared but unused", "Remove the unused volume or mount it in a service.", { category: "best-practice" }),
|
|
13
|
-
DKRD003: auditRule("DKRD003", "merge-worthy", "guidance", "Service exposes SSH (port 22)", "Don't expose SSH from a container; use exec/ephemeral access instead.", { authority: [DOCKER_SEC] }),
|
|
14
|
-
DKRD010: auditRule("DKRD010", "report-only", "guidance", "apt-get install without --no-install-recommends", "Add --no-install-recommends to keep images small.", { category: "best-practice" }),
|
|
15
|
-
DKRD011: auditRule("DKRD011", "report-only", "guidance", "ADD used where COPY would do", "Prefer COPY unless fetching a URL or extracting an archive.", { category: "best-practice" }),
|
|
16
|
-
DKRD012: auditRule("DKRD012", "merge-worthy", "guidance", "Container runs as root: the final stage has no USER, or ends on USER root", "Add a non-root USER instruction to the final stage, after the root setup steps.", { authority: [DOCKER_SEC] }),
|
|
17
|
-
DKRD013: auditRule("DKRD013", "report-only", "guidance", "Whole build context copied before a dependency install", "Copy the dependency manifests, run the install, then copy the rest of the source.", { category: "efficiency" }),
|
|
18
|
-
DKRD014: auditRule("DKRD014", "report-only", "guidance", "Root-only RUN after a non-root USER", "Run package installs and user/ownership changes before switching USER.", { category: "correctness" }),
|
|
19
|
-
DKRD015: auditRule("DKRD015", "report-only", "guidance", "More than one CMD or ENTRYPOINT in a stage", "Keep one CMD and one ENTRYPOINT per stage; only the last takes effect.", { category: "correctness" }),
|
|
20
|
-
DKRD016: auditRule("DKRD016", "report-only", "guidance", "COPY --from names no earlier stage", "Name a stage defined earlier in the Dockerfile, or a tagged image.", { category: "correctness" }),
|
|
21
|
-
DKRD017: auditRule("DKRD017", "report-only", "guidance", "ARG before FROM is never used", "Use the ARG in a FROM line, declare it again in the stage that needs it, or remove it.", { category: "best-practice" }),
|
|
22
|
-
DKRD018: auditRule("DKRD018", "report-only", "guidance", "Relative WORKDIR", "Use an absolute WORKDIR path.", { category: "best-practice" }),
|
|
23
|
-
DKRD019: auditRule("DKRD019", "report-only", "guidance", "ADD of a remote URL without --checksum", "Add --checksum=sha256:<digest> to ADD of an http(s) URL.", { category: "security" }),
|
|
24
|
-
DKRD020: auditRule("DKRD020", "report-only", "guidance", "apt-get update in its own RUN", "Run apt-get update and apt-get install in the same RUN.", { category: "correctness" }),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// Prior art credits live beside the rules in ./audit-lineage.ts (see core audit/prior-art.ts).
|
|
28
|
-
applyLineage(dockerAuditCatalog, dockerAuditLineage);
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prior art for these audit rules: the open-source tools whose checks cover the
|
|
3
|
-
* same condition, credited per rule. See packages/core/src/audit/prior-art.ts for
|
|
4
|
-
* the registry, the relation vocabulary, and why this is credit rather than
|
|
5
|
-
* authority. Kept by hand; the prior-art sweep (scripts/prior-art-sweep.ts) reports
|
|
6
|
-
* when a credited tool's index no longer lists a rule cited here.
|
|
7
|
-
*/
|
|
8
|
-
import type { Lineage } from "@intentius/chant/audit/catalog";
|
|
9
|
-
|
|
10
|
-
export const dockerAuditLineage: Record<string, Lineage[]> = {
|
|
11
|
-
DKRD001: [
|
|
12
|
-
{ tool: "hadolint", rule: "DL3007", url: "https://github.com/hadolint/hadolint/wiki/DL3007", relation: "overlaps" },
|
|
13
|
-
{ tool: "checkov", rule: "CKV_DOCKER_7", url: "https://www.checkov.io/5.Policy%20Index/dockerfile.html", relation: "overlaps" },
|
|
14
|
-
{ tool: "kics", rule: "image_version_using_latest", url: "https://docs.kics.io/latest/queries/dockerfile-queries/f45ea400-6bbe-4501-9fc7-1c3d75c32067/", relation: "overlaps" },
|
|
15
|
-
],
|
|
16
|
-
DKRD003: [
|
|
17
|
-
{ tool: "checkov", rule: "CKV_DOCKER_1", url: "https://www.checkov.io/5.Policy%20Index/dockerfile.html", relation: "overlaps" },
|
|
18
|
-
{ tool: "kics", rule: "Exposing Port 22 (SSH)", url: "https://docs.kics.io/latest/queries/dockerfile-queries/5907595b-5b6d-4142-b173-dbb0e73fbff8/", relation: "overlaps" },
|
|
19
|
-
],
|
|
20
|
-
DKRD010: [
|
|
21
|
-
{ tool: "hadolint", rule: "DL3015", url: "https://github.com/hadolint/hadolint/wiki/DL3015", relation: "equivalent" },
|
|
22
|
-
{ tool: "kics", rule: "apt_get_not_avoiding_additional_packages", url: "https://docs.kics.io/latest/queries/dockerfile-queries/7384dfb2-fcd1-4fbf-91cd-6c44c318c33c/", relation: "equivalent" },
|
|
23
|
-
],
|
|
24
|
-
DKRD011: [
|
|
25
|
-
{ tool: "hadolint", rule: "DL3020", url: "https://github.com/hadolint/hadolint/wiki/DL3020", relation: "equivalent" },
|
|
26
|
-
{ tool: "checkov", rule: "CKV_DOCKER_4", url: "https://www.checkov.io/5.Policy%20Index/dockerfile.html", relation: "overlaps" },
|
|
27
|
-
{ tool: "dockle", rule: "CIS-DI-0009", url: "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#cis-di-0009", relation: "overlaps" },
|
|
28
|
-
],
|
|
29
|
-
DKRD012: [
|
|
30
|
-
{ tool: "checkov", rule: "CKV_DOCKER_3", url: "https://www.checkov.io/5.Policy%20Index/dockerfile.html", relation: "equivalent" },
|
|
31
|
-
{ tool: "kics", rule: "missing_user_instruction", url: "https://docs.kics.io/latest/queries/dockerfile-queries/fd54f200-402c-4333-a5a4-36ef6709af2f/", relation: "equivalent" },
|
|
32
|
-
{ tool: "dockle", rule: "CIS-DI-0001", url: "https://github.com/goodwithtech/dockle/blob/master/CHECKPOINT.md#cis-di-0001", relation: "overlaps" },
|
|
33
|
-
{ tool: "hadolint", rule: "DL3002", url: "https://github.com/hadolint/hadolint/wiki/DL3002", relation: "overlaps" },
|
|
34
|
-
],
|
|
35
|
-
DKRD015: [
|
|
36
|
-
{ tool: "hadolint", rule: "DL4003", url: "https://github.com/hadolint/hadolint/wiki/DL4003", relation: "overlaps" },
|
|
37
|
-
{ tool: "hadolint", rule: "DL4004", url: "https://github.com/hadolint/hadolint/wiki/DL4004", relation: "overlaps" },
|
|
38
|
-
],
|
|
39
|
-
DKRD016: [
|
|
40
|
-
{ tool: "hadolint", rule: "DL3022", url: "https://github.com/hadolint/hadolint/wiki/DL3022", relation: "overlaps" },
|
|
41
|
-
],
|
|
42
|
-
DKRD018: [
|
|
43
|
-
{ tool: "hadolint", rule: "DL3000", url: "https://github.com/hadolint/hadolint/wiki/DL3000", relation: "overlaps" },
|
|
44
|
-
],
|
|
45
|
-
DKRD020: [
|
|
46
|
-
{ tool: "checkov", rule: "CKV_DOCKER_5", url: "https://www.checkov.io/5.Policy%20Index/dockerfile.html", relation: "overlaps" },
|
|
47
|
-
],
|
|
48
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DKRD019: ADD of a remote URL without --checksum
|
|
3
|
-
*
|
|
4
|
-
* ADD fetches an http(s) URL at build time and trusts whatever comes back.
|
|
5
|
-
* `ADD --checksum=sha256:...` makes the build fail when the content changes.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
9
|
-
import { eachDockerfile, stageLabel } from "./docker-helpers";
|
|
10
|
-
|
|
11
|
-
export const dkrd019: PostSynthCheck = {
|
|
12
|
-
id: "DKRD019",
|
|
13
|
-
description: "ADD fetches a remote URL without --checksum",
|
|
14
|
-
|
|
15
|
-
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
16
|
-
const diagnostics: PostSynthDiagnostic[] = [];
|
|
17
|
-
|
|
18
|
-
for (const { fileName, parsed } of eachDockerfile(ctx.outputs)) {
|
|
19
|
-
for (const stage of parsed.stages) {
|
|
20
|
-
for (const instr of stage.instructions) {
|
|
21
|
-
if (instr.instruction !== "ADD") continue;
|
|
22
|
-
const words = instr.value.split(/\s+/);
|
|
23
|
-
if (words.some((w) => w.startsWith("--checksum="))) continue;
|
|
24
|
-
const url = words.find((w) => /^https?:\/\//i.test(w));
|
|
25
|
-
if (!url) continue;
|
|
26
|
-
diagnostics.push({
|
|
27
|
-
checkId: "DKRD019",
|
|
28
|
-
severity: "warning",
|
|
29
|
-
message: `${fileName} ${stageLabel(stage)}: ADD ${url} has no --checksum, so the build accepts whatever the URL serves. Add --checksum=sha256:<digest>.`,
|
|
30
|
-
lexicon: "docker",
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return diagnostics;
|
|
37
|
-
},
|
|
38
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DKRD010: apt-get install without --no-install-recommends
|
|
3
|
-
*
|
|
4
|
-
* Detects RUN instructions with apt-get install missing
|
|
5
|
-
* --no-install-recommends, which leads to bloated images.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
9
|
-
import { extractDockerfiles } from "./docker-helpers";
|
|
10
|
-
|
|
11
|
-
export const dkrd010: PostSynthCheck = {
|
|
12
|
-
id: "DKRD010",
|
|
13
|
-
description: "apt-get install without --no-install-recommends adds unnecessary packages",
|
|
14
|
-
|
|
15
|
-
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
16
|
-
const diagnostics: PostSynthDiagnostic[] = [];
|
|
17
|
-
|
|
18
|
-
for (const [_outputName, output] of ctx.outputs) {
|
|
19
|
-
const dockerfiles = extractDockerfiles(output);
|
|
20
|
-
|
|
21
|
-
for (const [fileName, content] of dockerfiles) {
|
|
22
|
-
const lines = content.split("\n");
|
|
23
|
-
for (let i = 0; i < lines.length; i++) {
|
|
24
|
-
const line = lines[i].trim();
|
|
25
|
-
if (
|
|
26
|
-
/^RUN\s+/.test(line) &&
|
|
27
|
-
line.includes("apt-get install") &&
|
|
28
|
-
!line.includes("--no-install-recommends")
|
|
29
|
-
) {
|
|
30
|
-
diagnostics.push({
|
|
31
|
-
checkId: "DKRD010",
|
|
32
|
-
severity: "warning",
|
|
33
|
-
message: `${fileName}: RUN apt-get install should use --no-install-recommends to reduce image size.`,
|
|
34
|
-
lexicon: "docker",
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return diagnostics;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DKRD020: apt-get update in its own RUN
|
|
3
|
-
*
|
|
4
|
-
* A RUN that only runs `apt-get update` is cached as its own layer, so a
|
|
5
|
-
* later `apt-get install` in another RUN can install from a stale package
|
|
6
|
-
* index. Update and install in the same RUN.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
10
|
-
import { commandText, eachDockerfile, stageLabel } from "./docker-helpers";
|
|
11
|
-
|
|
12
|
-
const UPDATE = /\bapt(-get)?\s+update\b/;
|
|
13
|
-
const INSTALL = /\bapt(-get)?\s+(install|upgrade|dist-upgrade)\b/;
|
|
14
|
-
|
|
15
|
-
export const dkrd020: PostSynthCheck = {
|
|
16
|
-
id: "DKRD020",
|
|
17
|
-
description: "apt-get update in a different RUN from apt-get install — the install can use a stale package index",
|
|
18
|
-
|
|
19
|
-
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
20
|
-
const diagnostics: PostSynthDiagnostic[] = [];
|
|
21
|
-
|
|
22
|
-
for (const { fileName, parsed } of eachDockerfile(ctx.outputs)) {
|
|
23
|
-
for (const stage of parsed.stages) {
|
|
24
|
-
const runs = stage.instructions.filter((i) => i.instruction === "RUN");
|
|
25
|
-
const updateAt = runs.findIndex((r) => UPDATE.test(commandText(r)) && !INSTALL.test(commandText(r)));
|
|
26
|
-
if (updateAt === -1) continue;
|
|
27
|
-
if (!runs.slice(updateAt + 1).some((r) => INSTALL.test(commandText(r)))) continue;
|
|
28
|
-
diagnostics.push({
|
|
29
|
-
checkId: "DKRD020",
|
|
30
|
-
severity: "warning",
|
|
31
|
-
message: `${fileName} ${stageLabel(stage)}: apt-get update runs in its own RUN, and a later RUN installs from that cached index. Run update and install in one RUN: apt-get update && apt-get install -y --no-install-recommends ...`,
|
|
32
|
-
lexicon: "docker",
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return diagnostics;
|
|
38
|
-
},
|
|
39
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DKRD013: Whole build context copied before installing dependencies
|
|
3
|
-
*
|
|
4
|
-
* `COPY . .` followed by a dependency install (npm ci, pip install -r,
|
|
5
|
-
* go mod download, ...) in the same stage invalidates the install layer on
|
|
6
|
-
* every source change. Copy the dependency manifests first, install, then
|
|
7
|
-
* copy the rest.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { commandText, eachDockerfile, instrText, stageLabel } from "./docker-helpers";
|
|
12
|
-
|
|
13
|
-
/** Installs whose inputs are a few manifest files rather than the whole source tree. */
|
|
14
|
-
const INSTALL = [
|
|
15
|
-
/\bnpm\s+(ci|install|i)(\s+--?[\w-]+(=\S+)?)*\s*($|&&|;|\|)/m,
|
|
16
|
-
/\byarn(\s+install)?(\s+--[\w-]+)*\s*($|&&|;|\|)/m,
|
|
17
|
-
/\bpnpm\s+(install|i)\b/,
|
|
18
|
-
/\bbun\s+install\b/,
|
|
19
|
-
/\bpip3?\s+install\b[^&;|]*\s-r\s/,
|
|
20
|
-
/\bpoetry\s+install\b/,
|
|
21
|
-
/\buv\s+sync\b/,
|
|
22
|
-
/\bpipenv\s+install\b/,
|
|
23
|
-
/\bgo\s+mod\s+download\b/,
|
|
24
|
-
/\bbundle\s+install\b/,
|
|
25
|
-
/\bcomposer\s+install\b/,
|
|
26
|
-
// A string, not a regex literal: the egress scan reads a bare `fetch` in code as a call.
|
|
27
|
-
new RegExp("\\bcargo\\s+fetch\\b"),
|
|
28
|
-
/\bdotnet\s+restore\b/,
|
|
29
|
-
/\bmvn\b[^&;|]*\bdependency:go-offline\b/,
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
/** `COPY . <dest>` (or `./`) from the build context, not from another stage. */
|
|
33
|
-
function copiesWholeContext(value: string): boolean {
|
|
34
|
-
const words = value.split(/\s+/).filter((w) => w.length > 0);
|
|
35
|
-
if (words.some((w) => w.startsWith("--from"))) return false;
|
|
36
|
-
const args = words.filter((w) => !w.startsWith("--"));
|
|
37
|
-
if (args[0]?.startsWith("[")) return false;
|
|
38
|
-
return args.slice(0, -1).some((src) => src === "." || src === "./");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const dkrd013: PostSynthCheck = {
|
|
42
|
-
id: "DKRD013",
|
|
43
|
-
description: "Whole build context copied before a dependency install — every source change re-runs the install",
|
|
44
|
-
|
|
45
|
-
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
46
|
-
const diagnostics: PostSynthDiagnostic[] = [];
|
|
47
|
-
|
|
48
|
-
for (const { fileName, parsed } of eachDockerfile(ctx.outputs)) {
|
|
49
|
-
for (const stage of parsed.stages) {
|
|
50
|
-
const copyAt = stage.instructions.findIndex((i) => i.instruction === "COPY" && copiesWholeContext(i.value));
|
|
51
|
-
if (copyAt === -1) continue;
|
|
52
|
-
const install = stage.instructions.slice(copyAt + 1).find((i) => i.instruction === "RUN" && INSTALL.some((re) => re.test(commandText(i))));
|
|
53
|
-
if (!install) continue;
|
|
54
|
-
diagnostics.push({
|
|
55
|
-
checkId: "DKRD013",
|
|
56
|
-
severity: "warning",
|
|
57
|
-
message: `${fileName} ${stageLabel(stage)}: ${instrText(stage.instructions[copyAt]!)} comes before ${instrText(install)}, so any source change re-runs the install. Copy the dependency manifests first, run the install, then copy the rest.`,
|
|
58
|
-
lexicon: "docker",
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return diagnostics;
|
|
64
|
-
},
|
|
65
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DKRD016: COPY --from names no earlier stage
|
|
3
|
-
*
|
|
4
|
-
* `COPY --from=<name>` reads from an earlier stage with that name (or
|
|
5
|
-
* index). A name that only a later stage has, or that no stage has, is
|
|
6
|
-
* pulled as an image instead, which is almost never what was meant.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
10
|
-
import { eachDockerfile, stageLabel } from "./docker-helpers";
|
|
11
|
-
|
|
12
|
-
/** Looks like an image reference rather than a stage name: has a tag, digest or registry path. */
|
|
13
|
-
function looksLikeImage(ref: string): boolean {
|
|
14
|
-
return /[:/@]/.test(ref);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const dkrd016: PostSynthCheck = {
|
|
18
|
-
id: "DKRD016",
|
|
19
|
-
description: "COPY --from names a stage that is not defined before it",
|
|
20
|
-
|
|
21
|
-
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
22
|
-
const diagnostics: PostSynthDiagnostic[] = [];
|
|
23
|
-
|
|
24
|
-
for (const { fileName, parsed } of eachDockerfile(ctx.outputs)) {
|
|
25
|
-
for (const stage of parsed.stages) {
|
|
26
|
-
for (const instr of stage.instructions) {
|
|
27
|
-
if (instr.instruction !== "COPY" && instr.instruction !== "ADD") continue;
|
|
28
|
-
const m = instr.value.match(/--from=(\S+)/);
|
|
29
|
-
if (!m) continue;
|
|
30
|
-
const ref = m[1]!;
|
|
31
|
-
if (ref.includes("$")) continue;
|
|
32
|
-
const earlier = parsed.stages.slice(0, stage.index);
|
|
33
|
-
if (/^\d+$/.test(ref)) {
|
|
34
|
-
if (Number(ref) < stage.index) continue;
|
|
35
|
-
} else if (earlier.some((s) => s.as?.toLowerCase() === ref.toLowerCase())) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
const later = parsed.stages.slice(stage.index).find((s) => s.as?.toLowerCase() === ref.toLowerCase() || String(s.index) === ref);
|
|
39
|
-
if (!later && looksLikeImage(ref)) continue;
|
|
40
|
-
diagnostics.push({
|
|
41
|
-
checkId: "DKRD016",
|
|
42
|
-
severity: "warning",
|
|
43
|
-
message: later
|
|
44
|
-
? `${fileName} ${stageLabel(stage)}: ${instr.instruction} --from=${ref} names ${stageLabel(later)}, which is not defined until later. Move that stage before this one.`
|
|
45
|
-
: `${fileName} ${stageLabel(stage)}: ${instr.instruction} --from=${ref} names no stage, so Docker pulls an image called "${ref}". Name an earlier stage, or give the image a tag.`,
|
|
46
|
-
lexicon: "docker",
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return diagnostics;
|
|
53
|
-
},
|
|
54
|
-
};
|