@intentius/chant-lexicon-pulumi 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/adopt.d.ts +0 -1
- package/dist/capability-plugin.d.ts +0 -1
- package/dist/change-set.d.ts +0 -1
- package/dist/changed-units.d.ts +0 -1
- package/dist/check-step.d.ts +0 -1
- package/dist/ci-setup.d.ts +0 -1
- package/dist/codegen/docs-cli.d.ts +0 -1
- package/dist/codegen/docs.d.ts +0 -1
- package/dist/codegen/package.d.ts +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts +0 -1
- package/dist/composites/pulumi-watch-op.d.ts +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/describe-resources.d.ts +0 -1
- package/dist/drift-read.d.ts +0 -1
- package/dist/drift-record.d.ts +0 -1
- package/dist/engine-events.d.ts +0 -1
- package/dist/engine-graph.d.ts +0 -1
- package/dist/exit-codes.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/init-templates.d.ts +0 -1
- package/dist/integrity.json +2 -2
- package/dist/lint/audit-catalog.d.ts +0 -1
- package/dist/lint/post-synth/index.d.ts +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
- package/dist/lint/post-synth/pul001.d.ts +0 -1
- package/dist/lint/post-synth/pul002.d.ts +0 -1
- package/dist/lint/post-synth/pul003.d.ts +0 -1
- package/dist/lint/post-synth/pul004.d.ts +0 -1
- package/dist/lint/post-synth/pul005.d.ts +0 -1
- package/dist/lint/post-synth/pul006.d.ts +0 -1
- package/dist/lint/post-synth/pul007.d.ts +0 -1
- package/dist/lint/post-synth/pul008.d.ts +0 -1
- package/dist/lint/post-synth/pul009.d.ts +0 -1
- package/dist/lint/post-synth/pul010.d.ts +0 -1
- package/dist/lint/post-synth/pul011.d.ts +0 -1
- package/dist/lint/post-synth/pul012.d.ts +0 -1
- package/dist/lint/post-synth/pul013.d.ts +0 -1
- package/dist/lint/post-synth/pul014.d.ts +0 -1
- package/dist/lint/post-synth/pul015.d.ts +0 -1
- package/dist/lint/rules/index.d.ts +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
- package/dist/lock-rows.d.ts +0 -1
- package/dist/lsp/completions.d.ts +0 -1
- package/dist/lsp/documents.d.ts +0 -1
- package/dist/lsp/hover.d.ts +0 -1
- package/dist/lsp/keys.d.ts +0 -1
- package/dist/lsp/object-path.d.ts +0 -1
- package/dist/lsp/yaml-cursor.d.ts +0 -1
- package/dist/manifest.json +1 -1
- package/dist/member-engine.d.ts +0 -1
- package/dist/member-outputs.d.ts +0 -1
- package/dist/op/activities/index.d.ts +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts +0 -1
- package/dist/op/activities/pulumi.d.ts +0 -1
- package/dist/op/activity-contracts.d.ts +0 -1
- package/dist/op/builders.d.ts +0 -1
- package/dist/package-cli.d.ts +0 -1
- package/dist/plan-shape.d.ts +0 -1
- package/dist/planned-output-changes.d.ts +0 -1
- package/dist/plugin.d.ts +0 -1
- package/dist/plunge-timings.d.ts +0 -1
- package/dist/preview-tips.d.ts +0 -1
- package/dist/pulumi-up.d.ts +0 -1
- package/dist/release-copy.d.ts +0 -1
- package/dist/review-stack.d.ts +0 -1
- package/dist/run.d.ts +0 -1
- package/dist/serializer.d.ts +0 -1
- package/dist/stack-export-snapshot.d.ts +0 -1
- package/dist/stack-ops.d.ts +0 -1
- package/dist/stack-outputs.d.ts +0 -1
- package/dist/stack-references.d.ts +0 -1
- package/dist/trace-facts.d.ts +0 -1
- package/dist/values.d.ts +0 -1
- package/dist/workspace-member.d.ts +0 -1
- package/package.json +3 -4
- package/dist/adopt.d.ts.map +0 -1
- package/dist/capability-plugin.d.ts.map +0 -1
- package/dist/change-set.d.ts.map +0 -1
- package/dist/changed-units.d.ts.map +0 -1
- package/dist/check-step.d.ts.map +0 -1
- package/dist/ci-setup.d.ts.map +0 -1
- package/dist/codegen/docs-cli.d.ts.map +0 -1
- package/dist/codegen/docs.d.ts.map +0 -1
- package/dist/codegen/package.d.ts.map +0 -1
- package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
- package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/describe-resources.d.ts.map +0 -1
- package/dist/drift-read.d.ts.map +0 -1
- package/dist/drift-record.d.ts.map +0 -1
- package/dist/engine-events.d.ts.map +0 -1
- package/dist/engine-graph.d.ts.map +0 -1
- package/dist/exit-codes.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/init-templates.d.ts.map +0 -1
- package/dist/lint/audit-catalog.d.ts.map +0 -1
- package/dist/lint/post-synth/index.d.ts.map +0 -1
- package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
- package/dist/lint/post-synth/pul001.d.ts.map +0 -1
- package/dist/lint/post-synth/pul002.d.ts.map +0 -1
- package/dist/lint/post-synth/pul003.d.ts.map +0 -1
- package/dist/lint/post-synth/pul004.d.ts.map +0 -1
- package/dist/lint/post-synth/pul005.d.ts.map +0 -1
- package/dist/lint/post-synth/pul006.d.ts.map +0 -1
- package/dist/lint/post-synth/pul007.d.ts.map +0 -1
- package/dist/lint/post-synth/pul008.d.ts.map +0 -1
- package/dist/lint/post-synth/pul009.d.ts.map +0 -1
- package/dist/lint/post-synth/pul010.d.ts.map +0 -1
- package/dist/lint/post-synth/pul011.d.ts.map +0 -1
- package/dist/lint/post-synth/pul012.d.ts.map +0 -1
- package/dist/lint/post-synth/pul013.d.ts.map +0 -1
- package/dist/lint/post-synth/pul014.d.ts.map +0 -1
- package/dist/lint/post-synth/pul015.d.ts.map +0 -1
- package/dist/lint/rules/index.d.ts.map +0 -1
- package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
- package/dist/lock-rows.d.ts.map +0 -1
- package/dist/lsp/completions.d.ts.map +0 -1
- package/dist/lsp/documents.d.ts.map +0 -1
- package/dist/lsp/hover.d.ts.map +0 -1
- package/dist/lsp/keys.d.ts.map +0 -1
- package/dist/lsp/object-path.d.ts.map +0 -1
- package/dist/lsp/yaml-cursor.d.ts.map +0 -1
- package/dist/member-engine.d.ts.map +0 -1
- package/dist/member-outputs.d.ts.map +0 -1
- package/dist/op/activities/index.d.ts.map +0 -1
- package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
- package/dist/op/activities/pulumi.d.ts.map +0 -1
- package/dist/op/activity-contracts.d.ts.map +0 -1
- package/dist/op/builders.d.ts.map +0 -1
- package/dist/package-cli.d.ts.map +0 -1
- package/dist/plan-shape.d.ts.map +0 -1
- package/dist/planned-output-changes.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plunge-timings.d.ts.map +0 -1
- package/dist/preview-tips.d.ts.map +0 -1
- package/dist/pulumi-up.d.ts.map +0 -1
- package/dist/release-copy.d.ts.map +0 -1
- package/dist/review-stack.d.ts.map +0 -1
- package/dist/run.d.ts.map +0 -1
- package/dist/serializer.d.ts.map +0 -1
- package/dist/stack-export-snapshot.d.ts.map +0 -1
- package/dist/stack-ops.d.ts.map +0 -1
- package/dist/stack-outputs.d.ts.map +0 -1
- package/dist/stack-references.d.ts.map +0 -1
- package/dist/trace-facts.d.ts.map +0 -1
- package/dist/values.d.ts.map +0 -1
- package/dist/workspace-member.d.ts.map +0 -1
- package/src/adopt.ts +0 -202
- package/src/capability-plugin.ts +0 -34
- package/src/change-set.test.ts +0 -245
- package/src/change-set.ts +0 -508
- package/src/changed-units.test.ts +0 -87
- package/src/changed-units.ts +0 -96
- package/src/check-step.test.ts +0 -191
- package/src/check-step.ts +0 -316
- package/src/ci-setup.test.ts +0 -234
- package/src/ci-setup.ts +0 -224
- package/src/codegen/docs-cli.ts +0 -4
- package/src/codegen/docs.ts +0 -58
- package/src/codegen/package.ts +0 -63
- package/src/composites/pulumi-adopt-op.test.ts +0 -258
- package/src/composites/pulumi-adopt-op.ts +0 -193
- package/src/composites/pulumi-watch-op.test.ts +0 -42
- package/src/composites/pulumi-watch-op.ts +0 -85
- package/src/config.ts +0 -43
- package/src/describe-resources.test.ts +0 -112
- package/src/describe-resources.ts +0 -118
- package/src/drift-read.test.ts +0 -178
- package/src/drift-read.ts +0 -94
- package/src/drift-record.test.ts +0 -197
- package/src/drift-record.ts +0 -326
- package/src/engine-events.test.ts +0 -160
- package/src/engine-events.ts +0 -395
- package/src/engine-graph.test.ts +0 -141
- package/src/engine-graph.ts +0 -149
- package/src/exit-codes.test.ts +0 -21
- package/src/exit-codes.ts +0 -71
- package/src/index.ts +0 -139
- package/src/init-templates.ts +0 -85
- package/src/lint/audit-catalog.test.ts +0 -33
- package/src/lint/audit-catalog.ts +0 -174
- package/src/lint/post-synth/index.ts +0 -35
- package/src/lint/post-synth/member-read-helpers.ts +0 -122
- package/src/lint/post-synth/post-synth.test.ts +0 -245
- package/src/lint/post-synth/pul001.ts +0 -38
- package/src/lint/post-synth/pul002.ts +0 -38
- package/src/lint/post-synth/pul003.ts +0 -43
- package/src/lint/post-synth/pul004.ts +0 -32
- package/src/lint/post-synth/pul005.ts +0 -31
- package/src/lint/post-synth/pul006.ts +0 -31
- package/src/lint/post-synth/pul007.ts +0 -35
- package/src/lint/post-synth/pul008.ts +0 -35
- package/src/lint/post-synth/pul009.ts +0 -32
- package/src/lint/post-synth/pul010.ts +0 -42
- package/src/lint/post-synth/pul011.ts +0 -38
- package/src/lint/post-synth/pul012.ts +0 -35
- package/src/lint/post-synth/pul013.ts +0 -35
- package/src/lint/post-synth/pul014.ts +0 -32
- package/src/lint/post-synth/pul015.ts +0 -39
- package/src/lint/rules/index.ts +0 -7
- package/src/lint/rules/member-dir-absolute.test.ts +0 -37
- package/src/lint/rules/member-dir-absolute.ts +0 -83
- package/src/lock-rows.test.ts +0 -60
- package/src/lock-rows.ts +0 -56
- package/src/lsp/completions.test.ts +0 -69
- package/src/lsp/completions.ts +0 -119
- package/src/lsp/documents.ts +0 -48
- package/src/lsp/hover.test.ts +0 -56
- package/src/lsp/hover.ts +0 -83
- package/src/lsp/keys.ts +0 -169
- package/src/lsp/object-path.ts +0 -71
- package/src/lsp/yaml-cursor.ts +0 -85
- package/src/member-engine.test.ts +0 -112
- package/src/member-engine.ts +0 -97
- package/src/member-outputs.test.ts +0 -339
- package/src/member-outputs.ts +0 -157
- package/src/op/activities/index.ts +0 -36
- package/src/op/activities/pulumi-adopt.ts +0 -345
- package/src/op/activities/pulumi.ts +0 -136
- package/src/op/activity-contracts.ts +0 -129
- package/src/op/builders.ts +0 -67
- package/src/package-cli.ts +0 -14
- package/src/plan-shape.test.ts +0 -91
- package/src/plan-shape.ts +0 -105
- package/src/planned-output-changes.test.ts +0 -85
- package/src/planned-output-changes.ts +0 -141
- package/src/plugin.test.ts +0 -96
- package/src/plugin.ts +0 -272
- package/src/plunge-timings.test.ts +0 -241
- package/src/plunge-timings.ts +0 -115
- package/src/plunge-up-failed.test.ts +0 -54
- package/src/pr-note.test.ts +0 -87
- package/src/preview-generated.test.ts +0 -124
- package/src/preview-tips.test.ts +0 -134
- package/src/preview-tips.ts +0 -128
- package/src/pulumi-up.test.ts +0 -581
- package/src/pulumi-up.ts +0 -1102
- package/src/pulumi-urn-node.test.ts +0 -94
- package/src/release-copy.test.ts +0 -162
- package/src/release-copy.ts +0 -223
- package/src/review-stack.test.ts +0 -254
- package/src/review-stack.ts +0 -266
- package/src/run-plan-flags.test.ts +0 -53
- package/src/run.test.ts +0 -540
- package/src/run.ts +0 -1129
- package/src/serializer.test.ts +0 -9
- package/src/serializer.ts +0 -15
- package/src/skills/chant-pulumi-plunge.md +0 -51
- package/src/skills/chant-pulumi-stack-export.md +0 -54
- package/src/skills/chant-pulumi.md +0 -83
- package/src/stack-export-snapshot.test.ts +0 -192
- package/src/stack-export-snapshot.ts +0 -312
- package/src/stack-ops.fake-binary.test.ts +0 -323
- package/src/stack-ops.test.ts +0 -511
- package/src/stack-ops.ts +0 -1082
- package/src/stack-outputs.ts +0 -66
- package/src/stack-references.test.ts +0 -96
- package/src/stack-references.ts +0 -110
- package/src/testdata/plunge-drift/README.md +0 -10
- package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
- package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
- package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
- package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
- package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
- package/src/testdata/plunge-graph/README.md +0 -12
- package/src/testdata/plunge-graph/engine-graph.json +0 -158
- package/src/testdata/plunge-graph/stack-export.json +0 -49
- package/src/testdata/plunge-member/Pulumi.yaml +0 -4
- package/src/testdata/plunge-member/README.md +0 -3
- package/src/testdata/plunge-member/stack-export.json +0 -480
- package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
- package/src/testdata/plunge-outputs/README.md +0 -7
- package/src/testdata/plunge-outputs/stack-export.json +0 -2003
- package/src/testdata/plunge-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-member/README.md +0 -50
- package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
- package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-member/recording/index.js +0 -47
- package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
- package/src/testdata/pulumi-member/recording/package.json +0 -9
- package/src/testdata/pulumi-member/stack-export.json +0 -746
- package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-outputs/README.md +0 -9
- package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
- package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
- package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
- package/src/testdata/pulumi-outputs/stack-output.json +0 -19
- package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-preview/README.md +0 -9
- package/src/testdata/pulumi-preview/preview-create.json +0 -992
- package/src/testdata/pulumi-preview/preview.json +0 -2894
- package/src/testdata/pulumi-preview/stack-export.json +0 -1919
- package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-refresh/README.md +0 -14
- package/src/testdata/pulumi-refresh/all.json +0 -3742
- package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
- package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
- package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
- package/src/testdata/pulumi-refresh/role-same.json +0 -242
- package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
- package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
- package/src/testdata/pulumi-stream/README.md +0 -16
- package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
- package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
- package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
- package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
- package/src/testdata/pulumi-urn-node/README.md +0 -9
- package/src/testdata/pulumi-urn-node/preview.json +0 -2894
- package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
- package/src/trace-facts.test.ts +0 -38
- package/src/trace-facts.ts +0 -83
- package/src/values.ts +0 -147
- package/src/workspace-kinds.test.ts +0 -47
- package/src/workspace-member.test.ts +0 -127
- package/src/workspace-member.ts +0 -304
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL003: the stack export holds secrets in plaintext.
|
|
3
|
-
*
|
|
4
|
-
* `pulumi stack export` writes each secret as an envelope holding its
|
|
5
|
-
* `ciphertext`, encrypted with the stack's secrets provider. With
|
|
6
|
-
* `--show-secrets` it writes the same envelope with `plaintext` instead. The
|
|
7
|
-
* export chant reads is checked in, so an export taken with `--show-secrets`
|
|
8
|
-
* puts every secret value of the stack into the repository's history.
|
|
9
|
-
*
|
|
10
|
-
* An error: the leak is in the repository whether or not chant reads it, and
|
|
11
|
-
* re-exporting without `--show-secrets` (and rotating what leaked) is the
|
|
12
|
-
* fix. chant never copies inputs or outputs into the graph, so the graph
|
|
13
|
-
* itself carries none of them.
|
|
14
|
-
*/
|
|
15
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
16
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
17
|
-
import { entityOf, finding, listed, memberExport, plaintextSecretPaths } from "./member-read-helpers";
|
|
18
|
-
|
|
19
|
-
export const pul003: PostSynthCheck = {
|
|
20
|
-
id: "PUL003",
|
|
21
|
-
description: "The pulumi member's stack export holds secret values in plaintext (exported with --show-secrets)",
|
|
22
|
-
|
|
23
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
24
|
-
const exp = memberExport();
|
|
25
|
-
if (!exp) return [];
|
|
26
|
-
const out: PostSynthDiagnostic[] = [];
|
|
27
|
-
for (const r of exp.resources) {
|
|
28
|
-
const paths = plaintextSecretPaths(r);
|
|
29
|
-
if (paths.length === 0) continue;
|
|
30
|
-
out.push(
|
|
31
|
-
finding(
|
|
32
|
-
"PUL003",
|
|
33
|
-
"error",
|
|
34
|
-
`${PULUMI_EXPORT_FILE} holds ${paths.length} secret value(s) of ${r.urn} in plaintext (${listed(paths)}): ` +
|
|
35
|
-
`it was exported with --show-secrets. Export again with \`pulumi stack export --file ${PULUMI_EXPORT_FILE}\` ` +
|
|
36
|
-
`(no --show-secrets), and rotate the secrets the committed file exposed.`,
|
|
37
|
-
entityOf(exp.read, r.urn),
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return out;
|
|
42
|
-
},
|
|
43
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL004: the stack export holds resources pending deletion.
|
|
3
|
-
*
|
|
4
|
-
* A create-before-delete replacement creates the new resource, then deletes
|
|
5
|
-
* the old one. When the delete fails, Pulumi keeps the old resource in the
|
|
6
|
-
* state with `delete: true` under the same URN, and the next `pulumi up`
|
|
7
|
-
* tries the delete again. Until then the stack owns two cloud objects for
|
|
8
|
-
* one URN. The graph has one node per URN, so the old object has no node of
|
|
9
|
-
* its own, and drift for that URN reads the live resource only.
|
|
10
|
-
*/
|
|
11
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
12
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
13
|
-
import { entityOf, finding, flagged, memberExport } from "./member-read-helpers";
|
|
14
|
-
|
|
15
|
-
export const pul004: PostSynthCheck = {
|
|
16
|
-
id: "PUL004",
|
|
17
|
-
description: "The pulumi member's stack export holds replaced resources whose delete failed (delete: true)",
|
|
18
|
-
|
|
19
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
20
|
-
const exp = memberExport();
|
|
21
|
-
if (!exp) return [];
|
|
22
|
-
return flagged(exp.resources, "delete").map((r) =>
|
|
23
|
-
finding(
|
|
24
|
-
"PUL004",
|
|
25
|
-
"warning",
|
|
26
|
-
`${PULUMI_EXPORT_FILE} holds ${r.urn} marked delete: true, the old object of a replacement whose delete failed. ` +
|
|
27
|
-
`The stack owns two objects for this URN and the graph shows one. Run \`pulumi up\` to retry the delete, then export again.`,
|
|
28
|
-
entityOf(exp.read, r.urn),
|
|
29
|
-
),
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL005: the stack export holds resources pending replacement.
|
|
3
|
-
*
|
|
4
|
-
* A delete-before-create replacement deletes the old resource first and
|
|
5
|
-
* marks it `pendingReplacement: true` until the new one is created. An
|
|
6
|
-
* export that still carries the mark was taken after an update stopped
|
|
7
|
-
* between the two steps, so the cloud object behind the node may be gone.
|
|
8
|
-
* Its drift reads as missing until the next `pulumi up` creates it.
|
|
9
|
-
*/
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
12
|
-
import { entityOf, finding, flagged, memberExport } from "./member-read-helpers";
|
|
13
|
-
|
|
14
|
-
export const pul005: PostSynthCheck = {
|
|
15
|
-
id: "PUL005",
|
|
16
|
-
description: "The pulumi member's stack export holds resources deleted ahead of a replacement that never finished (pendingReplacement: true)",
|
|
17
|
-
|
|
18
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
19
|
-
const exp = memberExport();
|
|
20
|
-
if (!exp) return [];
|
|
21
|
-
return flagged(exp.resources, "pendingReplacement").map((r) =>
|
|
22
|
-
finding(
|
|
23
|
-
"PUL005",
|
|
24
|
-
"warning",
|
|
25
|
-
`${PULUMI_EXPORT_FILE} holds ${r.urn} marked pendingReplacement: true: it was deleted for a replacement that was never created, ` +
|
|
26
|
-
`so its node may stand for nothing in the cloud. Run \`pulumi up\` to finish the replacement, then export again.`,
|
|
27
|
-
entityOf(exp.read, r.urn),
|
|
28
|
-
),
|
|
29
|
-
);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL006: the stack export holds tainted resources.
|
|
3
|
-
*
|
|
4
|
-
* `pulumi state taint` marks a resource `taint: true`, and the next
|
|
5
|
-
* `pulumi up` replaces it whatever its inputs say. The member's preview
|
|
6
|
-
* already shows the replacement, so this is information: the change set's
|
|
7
|
-
* `replace` entry for the URN comes from the taint, not from a program
|
|
8
|
-
* change, which a reviewer reading the diff alone cannot see.
|
|
9
|
-
*/
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
12
|
-
import { entityOf, finding, flagged, memberExport } from "./member-read-helpers";
|
|
13
|
-
|
|
14
|
-
export const pul006: PostSynthCheck = {
|
|
15
|
-
id: "PUL006",
|
|
16
|
-
description: "The pulumi member's stack export holds tainted resources the next update replaces (taint: true)",
|
|
17
|
-
|
|
18
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
19
|
-
const exp = memberExport();
|
|
20
|
-
if (!exp) return [];
|
|
21
|
-
return flagged(exp.resources, "taint").map((r) =>
|
|
22
|
-
finding(
|
|
23
|
-
"PUL006",
|
|
24
|
-
"info",
|
|
25
|
-
`${PULUMI_EXPORT_FILE} holds ${r.urn} marked taint: true, so the next \`pulumi up\` replaces it ` +
|
|
26
|
-
`and the member's preview shows a replace that no program change explains. \`pulumi state untaint\` clears the mark.`,
|
|
27
|
-
entityOf(exp.read, r.urn),
|
|
28
|
-
),
|
|
29
|
-
);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL007: the configured stack is not the stack the export was taken from.
|
|
3
|
-
*
|
|
4
|
-
* `pulumi.member.stack` is the stack the drift read passes as `--stack`
|
|
5
|
-
* (#4496). The graph comes from the checked-in export, whose URNs name the
|
|
6
|
-
* stack it was taken from. When the two differ, the nodes are one stack's
|
|
7
|
-
* resources and the drift records are another's: a URN only one of them
|
|
8
|
-
* holds reads as not-observed, and every other record lands on a node it
|
|
9
|
-
* does not describe.
|
|
10
|
-
*/
|
|
11
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
12
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
13
|
-
import { finding, memberExport, urnScopes } from "./member-read-helpers";
|
|
14
|
-
|
|
15
|
-
export const pul007: PostSynthCheck = {
|
|
16
|
-
id: "PUL007",
|
|
17
|
-
description: "pulumi.member.stack names a stack other than the one the checked-in stack export was taken from",
|
|
18
|
-
|
|
19
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
20
|
-
const exp = memberExport();
|
|
21
|
-
const configured = exp?.read.stack;
|
|
22
|
-
if (!exp || !configured) return [];
|
|
23
|
-
const { stacks } = urnScopes(exp.resources);
|
|
24
|
-
if (stacks.length !== 1 || stacks[0] === configured) return [];
|
|
25
|
-
return [
|
|
26
|
-
finding(
|
|
27
|
-
"PUL007",
|
|
28
|
-
"warning",
|
|
29
|
-
`pulumi.member.stack is "${configured}", but ${PULUMI_EXPORT_FILE} was taken from stack "${stacks[0]}": ` +
|
|
30
|
-
`the graph shows one stack and drift reads the other. Export "${configured}" ` +
|
|
31
|
-
`(\`pulumi stack export --stack ${configured} --file ${PULUMI_EXPORT_FILE}\`) or set the stack the export names.`,
|
|
32
|
-
),
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL008: the export's URNs name more than one stack or project.
|
|
3
|
-
*
|
|
4
|
-
* Pulumi writes one stack's resources to an export, all under one
|
|
5
|
-
* `urn:pulumi:<stack>::<project>::` prefix. A node key drops that prefix
|
|
6
|
-
* (`@intentius/chant/pulumi-urn`), so two stacks' copies of a resource fall
|
|
7
|
-
* on one node, and the drift read cannot tell which stack to pass as
|
|
8
|
-
* `--stack`. An export like this was merged or edited by hand.
|
|
9
|
-
*/
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
12
|
-
import { finding, memberExport, urnScopes } from "./member-read-helpers";
|
|
13
|
-
|
|
14
|
-
export const pul008: PostSynthCheck = {
|
|
15
|
-
id: "PUL008",
|
|
16
|
-
description: "The pulumi member's stack export names more than one stack or project in its URNs",
|
|
17
|
-
|
|
18
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
19
|
-
const exp = memberExport();
|
|
20
|
-
if (!exp) return [];
|
|
21
|
-
const { stacks, projects } = urnScopes(exp.resources);
|
|
22
|
-
const parts: string[] = [];
|
|
23
|
-
if (stacks.length > 1) parts.push(`stacks ${stacks.join(", ")}`);
|
|
24
|
-
if (projects.length > 1) parts.push(`projects ${projects.join(", ")}`);
|
|
25
|
-
if (parts.length === 0) return [];
|
|
26
|
-
return [
|
|
27
|
-
finding(
|
|
28
|
-
"PUL008",
|
|
29
|
-
"warning",
|
|
30
|
-
`${PULUMI_EXPORT_FILE} names ${parts.join(" and ")} in its URNs. Node ids drop the stack and project, ` +
|
|
31
|
-
`so resources of different stacks share nodes. Replace the file with one \`pulumi stack export\`.`,
|
|
32
|
-
),
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL009: the export was taken from another project.
|
|
3
|
-
*
|
|
4
|
-
* Every URN in an export names the project it belongs to, and `Pulumi.yaml`'s
|
|
5
|
-
* `name` is the member's project. When they differ, the checked-in export is
|
|
6
|
-
* some other program's (copied in, or left from before a rename), and the
|
|
7
|
-
* graph shows resources this member's preview and refresh never touch.
|
|
8
|
-
*/
|
|
9
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
10
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
11
|
-
import { finding, memberExport, pulumiYamlName, urnScopes } from "./member-read-helpers";
|
|
12
|
-
|
|
13
|
-
export const pul009: PostSynthCheck = {
|
|
14
|
-
id: "PUL009",
|
|
15
|
-
description: "The pulumi member's stack export belongs to a project other than the one Pulumi.yaml names",
|
|
16
|
-
|
|
17
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
18
|
-
const exp = memberExport();
|
|
19
|
-
if (!exp) return [];
|
|
20
|
-
const name = pulumiYamlName(exp.read.dir);
|
|
21
|
-
const { projects } = urnScopes(exp.resources);
|
|
22
|
-
if (!name || projects.length !== 1 || projects[0] === name) return [];
|
|
23
|
-
return [
|
|
24
|
-
finding(
|
|
25
|
-
"PUL009",
|
|
26
|
-
"warning",
|
|
27
|
-
`${PULUMI_EXPORT_FILE} was taken from project "${projects[0]}", but Pulumi.yaml names "${name}": ` +
|
|
28
|
-
`the graph shows another program's resources. Export this member's own stack again.`,
|
|
29
|
-
),
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL010: a resource's parent or dependency is not in the export.
|
|
3
|
-
*
|
|
4
|
-
* Edges come from each resource's `parent` and `dependencies`
|
|
5
|
-
* (`../../workspace-member.ts`), and an edge to a URN the export does not
|
|
6
|
-
* hold is dropped without a word. Pulumi's own integrity check refuses a
|
|
7
|
-
* deployment whose resources name a parent or dependency it does not hold,
|
|
8
|
-
* so an export like this was edited by hand or cut short, and the graph is
|
|
9
|
-
* missing the edges it names.
|
|
10
|
-
*/
|
|
11
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
12
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
13
|
-
import { entityOf, finding, listed, memberExport } from "./member-read-helpers";
|
|
14
|
-
|
|
15
|
-
export const pul010: PostSynthCheck = {
|
|
16
|
-
id: "PUL010",
|
|
17
|
-
description: "A resource in the pulumi member's stack export names a parent or dependency the export does not hold",
|
|
18
|
-
|
|
19
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
20
|
-
const exp = memberExport();
|
|
21
|
-
if (!exp) return [];
|
|
22
|
-
const held = new Set(exp.resources.map((r) => r.urn));
|
|
23
|
-
const out: PostSynthDiagnostic[] = [];
|
|
24
|
-
for (const r of exp.resources) {
|
|
25
|
-
const named = [r.parent, ...(Array.isArray(r.dependencies) ? r.dependencies : [])].filter(
|
|
26
|
-
(u): u is string => typeof u === "string" && u.length > 0,
|
|
27
|
-
);
|
|
28
|
-
const dangling = [...new Set(named.filter((u) => !held.has(u)))];
|
|
29
|
-
if (dangling.length === 0) continue;
|
|
30
|
-
out.push(
|
|
31
|
-
finding(
|
|
32
|
-
"PUL010",
|
|
33
|
-
"warning",
|
|
34
|
-
`${r.urn} names ${dangling.length} parent or dependency URN(s) ${PULUMI_EXPORT_FILE} does not hold (${listed(dangling)}), ` +
|
|
35
|
-
`so the graph has no edge for them. Replace the file with a fresh \`pulumi stack export\`.`,
|
|
36
|
-
entityOf(exp.read, r.urn),
|
|
37
|
-
),
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
return out;
|
|
41
|
-
},
|
|
42
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL011: two live resources in the export share a URN.
|
|
3
|
-
*
|
|
4
|
-
* A URN names one resource. The only state that holds two entries for one
|
|
5
|
-
* URN is a replacement in flight, where the old entry is marked
|
|
6
|
-
* `delete: true` (PUL004 reports those). Two entries with neither mark come
|
|
7
|
-
* from a hand-merged export, which `pulumi stack import` refuses. The graph
|
|
8
|
-
* keeps the last one, so the other has no node.
|
|
9
|
-
*/
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
12
|
-
import { entityOf, finding, memberExport } from "./member-read-helpers";
|
|
13
|
-
|
|
14
|
-
export const pul011: PostSynthCheck = {
|
|
15
|
-
id: "PUL011",
|
|
16
|
-
description: "Two resources in the pulumi member's stack export share a URN and neither is pending deletion",
|
|
17
|
-
|
|
18
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
19
|
-
const exp = memberExport();
|
|
20
|
-
if (!exp) return [];
|
|
21
|
-
const count = new Map<string, number>();
|
|
22
|
-
for (const r of exp.resources) {
|
|
23
|
-
if (r.delete === true) continue;
|
|
24
|
-
count.set(r.urn, (count.get(r.urn) ?? 0) + 1);
|
|
25
|
-
}
|
|
26
|
-
return [...count]
|
|
27
|
-
.filter(([, n]) => n > 1)
|
|
28
|
-
.map(([urn, n]) =>
|
|
29
|
-
finding(
|
|
30
|
-
"PUL011",
|
|
31
|
-
"warning",
|
|
32
|
-
`${PULUMI_EXPORT_FILE} holds ${n} live entries for ${urn}; the graph keeps one. ` +
|
|
33
|
-
`Replace the file with a fresh \`pulumi stack export\`.`,
|
|
34
|
-
entityOf(exp.read, urn),
|
|
35
|
-
),
|
|
36
|
-
);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL012: the export holds resources the stack reads but does not manage.
|
|
3
|
-
*
|
|
4
|
-
* A resource a program reads with a `get` function (`aws.s3.Bucket.get`) is
|
|
5
|
-
* in the state with `external: true`. It is a node like any other, but the
|
|
6
|
-
* stack never creates, updates or deletes it, so a drift record on it shows
|
|
7
|
-
* a change some other owner made, and the member's preview never plans a fix
|
|
8
|
-
* for it. Information, so a reader of the graph knows which nodes this
|
|
9
|
-
* member only looks at.
|
|
10
|
-
*/
|
|
11
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
12
|
-
import { isPulumiNodeless } from "@intentius/chant/pulumi-urn";
|
|
13
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
14
|
-
import { finding, flagged, listed, memberExport } from "./member-read-helpers";
|
|
15
|
-
|
|
16
|
-
export const pul012: PostSynthCheck = {
|
|
17
|
-
id: "PUL012",
|
|
18
|
-
description: "The pulumi member's stack export holds resources the stack reads and does not manage (external: true)",
|
|
19
|
-
|
|
20
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
21
|
-
const exp = memberExport();
|
|
22
|
-
if (!exp) return [];
|
|
23
|
-
const external = flagged(exp.resources, "external").filter((r) => !isPulumiNodeless(r.type));
|
|
24
|
-
if (external.length === 0) return [];
|
|
25
|
-
return [
|
|
26
|
-
finding(
|
|
27
|
-
"PUL012",
|
|
28
|
-
"info",
|
|
29
|
-
`${PULUMI_EXPORT_FILE} holds ${external.length} resource(s) the program reads with a get function and does not manage ` +
|
|
30
|
-
`(${listed(external.map((r) => r.urn))}). They are nodes, but this member's preview never changes them, ` +
|
|
31
|
-
`so drift on them is another owner's.`,
|
|
32
|
-
),
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL013: the export's deployment version is not the one chant reads.
|
|
3
|
-
*
|
|
4
|
-
* `pulumi stack export` writes `{ "version": 3, "deployment": ... }`, and
|
|
5
|
-
* every reader in this lexicon (the graph, the change set's prior state, the
|
|
6
|
-
* drift read's URN list) is written and recorded against version 3
|
|
7
|
-
* (`../../testdata/`). An export with another version, or none, may lay its
|
|
8
|
-
* resources out differently, and what chant reads from it is not checked.
|
|
9
|
-
*/
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
12
|
-
import { finding, memberExport } from "./member-read-helpers";
|
|
13
|
-
|
|
14
|
-
/** The deployment schema version the readers are written against. */
|
|
15
|
-
export const PULUMI_EXPORT_VERSION = 3;
|
|
16
|
-
|
|
17
|
-
export const pul013: PostSynthCheck = {
|
|
18
|
-
id: "PUL013",
|
|
19
|
-
description: "The pulumi member's stack export has a deployment version other than 3, the one chant reads",
|
|
20
|
-
|
|
21
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
22
|
-
const exp = memberExport();
|
|
23
|
-
if (!exp) return [];
|
|
24
|
-
const version = exp.doc.version;
|
|
25
|
-
if (version === PULUMI_EXPORT_VERSION) return [];
|
|
26
|
-
return [
|
|
27
|
-
finding(
|
|
28
|
-
"PUL013",
|
|
29
|
-
"warning",
|
|
30
|
-
`${PULUMI_EXPORT_FILE} has ${version === undefined ? "no version" : `version ${JSON.stringify(version)}`}; ` +
|
|
31
|
-
`chant reads version ${PULUMI_EXPORT_VERSION}, what \`pulumi stack export\` writes, so the graph read from it is unchecked.`,
|
|
32
|
-
),
|
|
33
|
-
];
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL014: the export holds no resources.
|
|
3
|
-
*
|
|
4
|
-
* PUL001 covers a member with no export. An export that reads but holds
|
|
5
|
-
* nothing besides the root stack and its providers gives the same empty
|
|
6
|
-
* member, quietly: the stack was never deployed, was destroyed, or the file
|
|
7
|
-
* was exported from a fresh stack. Information, since an empty stack can be
|
|
8
|
-
* what the owner meant.
|
|
9
|
-
*/
|
|
10
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
11
|
-
import { isPulumiNodeless } from "@intentius/chant/pulumi-urn";
|
|
12
|
-
import { PULUMI_EXPORT_FILE } from "../../workspace-member";
|
|
13
|
-
import { finding, memberExport } from "./member-read-helpers";
|
|
14
|
-
|
|
15
|
-
export const pul014: PostSynthCheck = {
|
|
16
|
-
id: "PUL014",
|
|
17
|
-
description: "The pulumi member's stack export reads but holds no resources besides the stack and its providers",
|
|
18
|
-
|
|
19
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
20
|
-
const exp = memberExport();
|
|
21
|
-
if (!exp) return [];
|
|
22
|
-
if (exp.resources.some((r) => !isPulumiNodeless(r.type))) return [];
|
|
23
|
-
return [
|
|
24
|
-
finding(
|
|
25
|
-
"PUL014",
|
|
26
|
-
"info",
|
|
27
|
-
`${PULUMI_EXPORT_FILE} holds no resources besides the stack and its providers, so the member has no nodes. ` +
|
|
28
|
-
`If the stack has been deployed since, export it again after \`pulumi up\`.`,
|
|
29
|
-
),
|
|
30
|
-
];
|
|
31
|
-
},
|
|
32
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PUL015: the config says stock pulumi for a member on a plunge backend.
|
|
3
|
-
*
|
|
4
|
-
* `pulumi.member.engine` decides which binary runs the member's preview,
|
|
5
|
-
* outputs and drift; with none set, `plywood.yml`'s engine, a `plunge`
|
|
6
|
-
* `PULUMI_BACKEND_URL`, or a `backend.url` in `Pulumi.yaml` that
|
|
7
|
-
* starts with `plunge` means plunge (`../../run.ts`, `pulumiMemberEngine`).
|
|
8
|
-
* The config wins, so `engine: "pulumi"` on a program whose backend is
|
|
9
|
-
* `plunge+file://...` or `plunge://...` runs stock `pulumi` against a
|
|
10
|
-
* backend scheme only plunge opens, and every read fails.
|
|
11
|
-
*
|
|
12
|
-
* One direction only, by maintainer ruling (#4559): `engine: "plunge"` with a
|
|
13
|
-
* stock backend is not reported, because plunge opens stock backends and the
|
|
14
|
-
* config may mean it.
|
|
15
|
-
*/
|
|
16
|
-
import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
|
|
17
|
-
import { pulumiMemberEngine } from "../../run";
|
|
18
|
-
import { lastMemberRead } from "../../workspace-member";
|
|
19
|
-
import { finding } from "./member-read-helpers";
|
|
20
|
-
|
|
21
|
-
export const pul015: PostSynthCheck = {
|
|
22
|
-
id: "PUL015",
|
|
23
|
-
description: "pulumi.member.engine says pulumi, but the resolved engine is plunge",
|
|
24
|
-
|
|
25
|
-
check(_ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
26
|
-
const read = lastMemberRead();
|
|
27
|
-
if (read?.engine !== "pulumi") return [];
|
|
28
|
-
const implied = pulumiMemberEngine(read.dir);
|
|
29
|
-
if (implied.engine !== "plunge") return [];
|
|
30
|
-
return [
|
|
31
|
-
finding(
|
|
32
|
-
"PUL015",
|
|
33
|
-
"warning",
|
|
34
|
-
`pulumi.member.engine is "pulumi", but ${implied.because}. chant runs the configured engine, so the member's ` +
|
|
35
|
-
`preview, outputs and drift run stock pulumi against a backend only plunge opens. Drop \`engine\` or set it to "plunge".`,
|
|
36
|
-
),
|
|
37
|
-
];
|
|
38
|
-
},
|
|
39
|
-
};
|
package/src/lint/rules/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { LintRule } from "@intentius/chant/lint/rule";
|
|
2
|
-
import { memberDirAbsoluteRule } from "./member-dir-absolute";
|
|
3
|
-
|
|
4
|
-
export { memberDirAbsoluteRule } from "./member-dir-absolute";
|
|
5
|
-
|
|
6
|
-
/** All lint rules provided by this lexicon (imported by plugin.ts's lintRules()). */
|
|
7
|
-
export const rules: LintRule[] = [memberDirAbsoluteRule];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import * as ts from "typescript";
|
|
3
|
-
import type { LintContext } from "@intentius/chant/lint/rule";
|
|
4
|
-
import { isAbsolutePath, memberDirAbsoluteRule } from "./member-dir-absolute";
|
|
5
|
-
|
|
6
|
-
function createContext(code: string, fileName = "chant.config.ts"): LintContext {
|
|
7
|
-
const sourceFile = ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true);
|
|
8
|
-
return { sourceFile, entities: [], filePath: fileName };
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe("PUL101: pulumi.member.dir is absolute", () => {
|
|
12
|
-
test("flags an absolute dir in the config namespace", () => {
|
|
13
|
-
const diags = memberDirAbsoluteRule.check(
|
|
14
|
-
createContext(`export default { lexicons: ["pulumi"], pulumi: { member: { dir: "/home/me/infra", label: "infra" } } };`),
|
|
15
|
-
);
|
|
16
|
-
expect(diags).toHaveLength(1);
|
|
17
|
-
expect(diags[0].ruleId).toBe("PUL101");
|
|
18
|
-
expect(diags[0].severity).toBe("warning");
|
|
19
|
-
expect(diags[0].message).toContain("/home/me/infra");
|
|
20
|
-
expect(diags[0].line).toBe(1);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test("passes a relative dir", () => {
|
|
24
|
-
expect(memberDirAbsoluteRule.check(createContext(`export default { pulumi: { member: { dir: "./infra" } } };`))).toEqual([]);
|
|
25
|
-
expect(memberDirAbsoluteRule.check(createContext(`export default { pulumi: { member: { dir: "infra" } } };`))).toEqual([]);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("stays silent on a computed dir and on a dir outside pulumi.member", () => {
|
|
29
|
-
expect(memberDirAbsoluteRule.check(createContext(`export default { pulumi: { member: { dir: join(root, "infra") } } };`))).toEqual([]);
|
|
30
|
-
expect(memberDirAbsoluteRule.check(createContext(`export default { terraform: { roots: { app: { dir: "/abs" } } } };`))).toEqual([]);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("reads POSIX, home-relative and Windows absolute forms", () => {
|
|
34
|
-
for (const p of ["/x", "~/x", "C:\\x", "C:/x", "\\\\server\\share"]) expect(isAbsolutePath(p)).toBe(true);
|
|
35
|
-
for (const p of ["x", "./x", "../x"]) expect(isAbsolutePath(p)).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { ts } from "@intentius/chant/lint/typescript";
|
|
2
|
-
import type { LintContext, LintDiagnostic, LintRule } from "@intentius/chant/lint/rule";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* PUL101: `pulumi.member.dir` is an absolute path written in source.
|
|
6
|
-
*
|
|
7
|
-
* `chant workspace graph` writes `pulumi.member` into the reader project it
|
|
8
|
-
* makes for a member of kind `pulumi`, with `dir` absolute, because that
|
|
9
|
-
* project lives in a scratch directory and is thrown away. A project that
|
|
10
|
-
* writes the namespace itself (to read a member's graph into its own build,
|
|
11
|
-
* as `examples/workspace-member` does) commits the path, and an absolute one
|
|
12
|
-
* names a directory on the author's machine: on a CI runner or a second
|
|
13
|
-
* checkout the member is not found, and the build reads no graph (PUL001).
|
|
14
|
-
* A relative `dir` resolves against the project root, the directory that
|
|
15
|
-
* holds `chant.config.ts`, so it travels with the repository.
|
|
16
|
-
*
|
|
17
|
-
* Matches the literal shape only: a `pulumi: { member: { dir: "<literal>" } }`
|
|
18
|
-
* object, at any depth. A computed `dir` (`join(...)`, a template with
|
|
19
|
-
* substitutions, an identifier) is out of reach and stays silent.
|
|
20
|
-
*/
|
|
21
|
-
export const memberDirAbsoluteRule: LintRule = {
|
|
22
|
-
id: "PUL101",
|
|
23
|
-
severity: "warning",
|
|
24
|
-
category: "correctness",
|
|
25
|
-
description: "pulumi.member.dir is an absolute path; a relative dir resolves against the project root and travels with the repository",
|
|
26
|
-
|
|
27
|
-
check(context: LintContext): LintDiagnostic[] {
|
|
28
|
-
const diagnostics: LintDiagnostic[] = [];
|
|
29
|
-
const source = context.sourceFile;
|
|
30
|
-
|
|
31
|
-
const propName = (prop: ts.ObjectLiteralElementLike): string | undefined => {
|
|
32
|
-
if (!ts.isPropertyAssignment(prop)) return undefined;
|
|
33
|
-
if (ts.isIdentifier(prop.name) || ts.isStringLiteral(prop.name)) return prop.name.text;
|
|
34
|
-
return undefined;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const objectProp = (obj: ts.ObjectLiteralExpression, name: string): ts.ObjectLiteralExpression | undefined => {
|
|
38
|
-
for (const prop of obj.properties) {
|
|
39
|
-
if (propName(prop) !== name) continue;
|
|
40
|
-
const value = (prop as ts.PropertyAssignment).initializer;
|
|
41
|
-
if (ts.isObjectLiteralExpression(value)) return value;
|
|
42
|
-
}
|
|
43
|
-
return undefined;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const checkMember = (member: ts.ObjectLiteralExpression) => {
|
|
47
|
-
for (const prop of member.properties) {
|
|
48
|
-
if (propName(prop) !== "dir") continue;
|
|
49
|
-
const value = (prop as ts.PropertyAssignment).initializer;
|
|
50
|
-
if (!ts.isStringLiteral(value) && !ts.isNoSubstitutionTemplateLiteral(value)) continue;
|
|
51
|
-
if (!isAbsolutePath(value.text)) continue;
|
|
52
|
-
const { line, character } = source.getLineAndCharacterOfPosition(value.getStart(source));
|
|
53
|
-
diagnostics.push({
|
|
54
|
-
ruleId: "PUL101",
|
|
55
|
-
severity: "warning",
|
|
56
|
-
message:
|
|
57
|
-
`pulumi.member.dir "${value.text}" is an absolute path, which names a directory on this machine only. ` +
|
|
58
|
-
"Write it relative to the project root (the directory holding chant.config.ts), such as \"./infra\".",
|
|
59
|
-
file: context.filePath,
|
|
60
|
-
line: line + 1,
|
|
61
|
-
column: character + 1,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const visit = (node: ts.Node) => {
|
|
67
|
-
if (ts.isObjectLiteralExpression(node)) {
|
|
68
|
-
const pulumi = objectProp(node, "pulumi");
|
|
69
|
-
const member = pulumi ? objectProp(pulumi, "member") : undefined;
|
|
70
|
-
if (member) checkMember(member);
|
|
71
|
-
}
|
|
72
|
-
ts.forEachChild(node, visit);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
visit(source);
|
|
76
|
-
return diagnostics;
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/** POSIX `/x`, `~/x`, and Windows `C:\x` / `C:/x` or `\\server\share`. */
|
|
81
|
-
export function isAbsolutePath(p: string): boolean {
|
|
82
|
-
return p.startsWith("/") || p.startsWith("~/") || /^[A-Za-z]:[\\/]/.test(p) || p.startsWith("\\\\");
|
|
83
|
-
}
|