@prism-d1/cli 1.0.80 → 1.0.81
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/assets/github-workflows/prism-ai-metrics.yml +1 -1
- package/dist/assets/gitlab-workflows/prism-ai-metrics.yml +1 -1
- package/dist/assets/infra/lib/metrics-pipeline-stack.ts +3 -2
- package/dist/src/commands/assessment/web.d.ts.map +1 -1
- package/dist/src/commands/assessment/web.js +25 -2
- package/dist/src/commands/assessment/web.js.map +1 -1
- package/dist/src/commands/bootstrapper/install-eval-harness.d.ts.map +1 -1
- package/dist/src/commands/bootstrapper/install-eval-harness.js +15 -5
- package/dist/src/commands/bootstrapper/install-eval-harness.js.map +1 -1
- package/dist/src/commands/bootstrapper/install-git-hooks.d.ts.map +1 -1
- package/dist/src/commands/bootstrapper/install-git-hooks.js +10 -14
- package/dist/src/commands/bootstrapper/install-git-hooks.js.map +1 -1
- package/dist/src/commands/bootstrapper/setup-github-oidc.d.ts.map +1 -1
- package/dist/src/commands/bootstrapper/setup-github-oidc.js +50 -27
- package/dist/src/commands/bootstrapper/setup-github-oidc.js.map +1 -1
- package/dist/src/commands/bootstrapper/setup-gitlab-oidc.d.ts.map +1 -1
- package/dist/src/commands/bootstrapper/setup-gitlab-oidc.js +69 -25
- package/dist/src/commands/bootstrapper/setup-gitlab-oidc.js.map +1 -1
- package/dist/src/commands/bootstrapper/setup-otel-sync.d.ts.map +1 -1
- package/dist/src/commands/bootstrapper/setup-otel-sync.js +145 -53
- package/dist/src/commands/bootstrapper/setup-otel-sync.js.map +1 -1
- package/dist/src/commands/workshop/generate-demo-data.d.ts +41 -2
- package/dist/src/commands/workshop/generate-demo-data.d.ts.map +1 -1
- package/dist/src/commands/workshop/generate-demo-data.js +391 -167
- package/dist/src/commands/workshop/generate-demo-data.js.map +1 -1
- package/dist/src/commands/workshop/verify-setup.d.ts.map +1 -1
- package/dist/src/commands/workshop/verify-setup.js +75 -14
- package/dist/src/commands/workshop/verify-setup.js.map +1 -1
- package/dist/src/utils/exec.d.ts +56 -0
- package/dist/src/utils/exec.d.ts.map +1 -0
- package/dist/src/utils/exec.js +72 -0
- package/dist/src/utils/exec.js.map +1 -0
- package/dist/src/utils/tempfile.d.ts +19 -0
- package/dist/src/utils/tempfile.d.ts.map +1 -0
- package/dist/src/utils/tempfile.js +32 -0
- package/dist/src/utils/tempfile.js.map +1 -0
- package/dist/src/utils/validate.d.ts +54 -0
- package/dist/src/utils/validate.d.ts.map +1 -0
- package/dist/src/utils/validate.js +143 -0
- package/dist/src/utils/validate.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation for provider identity values collected at the prompt.
|
|
3
|
+
*
|
|
4
|
+
* These are NOT what prevents shell injection -- run() in ./exec.ts does that by
|
|
5
|
+
* never invoking a shell. Validation is here for two other reasons:
|
|
6
|
+
*
|
|
7
|
+
* 1. IAM role names are built from these values and accept only [\w+=,.@-].
|
|
8
|
+
* A value containing a slash or a space otherwise reaches AWS and comes back
|
|
9
|
+
* as a ValidationException that says nothing about which input was wrong.
|
|
10
|
+
* 2. Several of these values land inside an IAM trust policy condition. A
|
|
11
|
+
* malformed one does not fail loudly -- it produces a policy whose sub claim
|
|
12
|
+
* never matches (nothing can assume the role) or, worse, matches more
|
|
13
|
+
* broadly than intended.
|
|
14
|
+
*
|
|
15
|
+
* Each helper exits the process with a message naming the offending value rather
|
|
16
|
+
* than throwing, matching how the bootstrapper commands report other input
|
|
17
|
+
* errors.
|
|
18
|
+
*/
|
|
19
|
+
function fail(lines) {
|
|
20
|
+
for (const line of lines)
|
|
21
|
+
console.error(line);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
// ---- GitHub ----
|
|
25
|
+
/**
|
|
26
|
+
* GitHub owner (user or org): alphanumerics and hyphens, no leading or trailing
|
|
27
|
+
* hyphen, 39 characters max.
|
|
28
|
+
*
|
|
29
|
+
* Deliberately looser than GitHub's current signup rule, which forbids
|
|
30
|
+
* consecutive hyphens. That rule postdates a lot of accounts, so grandfathered
|
|
31
|
+
* owners containing `--` still exist and IAM accepts them fine. Rejecting one
|
|
32
|
+
* would block a legitimate user for no security gain.
|
|
33
|
+
*/
|
|
34
|
+
const GITHUB_OWNER = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/;
|
|
35
|
+
/** GitHub repository: alphanumerics plus `.`, `_`, `-`, 100 characters max. */
|
|
36
|
+
const GITHUB_REPO = /^[A-Za-z0-9._-]{1,100}$/;
|
|
37
|
+
export function validateGithubOwner(value, label = 'GitHub username/org') {
|
|
38
|
+
if (!GITHUB_OWNER.test(value)) {
|
|
39
|
+
fail([
|
|
40
|
+
`Error: ${label} "${value}" is not a valid GitHub owner name.`,
|
|
41
|
+
' Expected letters, digits, and hyphens (max 39 characters), not starting or ending with a hyphen.',
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
export function validateGithubRepo(value, label = 'Repository name') {
|
|
47
|
+
if (!GITHUB_REPO.test(value) || value === '.' || value === '..') {
|
|
48
|
+
fail([
|
|
49
|
+
`Error: ${label} "${value}" is not a valid GitHub repository name.`,
|
|
50
|
+
' Expected letters, digits, dots, underscores, and hyphens (max 100 characters).',
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
// ---- GitLab ----
|
|
56
|
+
/**
|
|
57
|
+
* One segment of a GitLab namespace or project path.
|
|
58
|
+
*
|
|
59
|
+
* GitLab permits letters, digits, `_`, `.`, `-`, requires the first character to
|
|
60
|
+
* be alphanumeric, and reserves the `.git` and `.atom` suffixes.
|
|
61
|
+
*/
|
|
62
|
+
const GITLAB_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$/;
|
|
63
|
+
function validGitlabSegment(seg) {
|
|
64
|
+
return GITLAB_SEGMENT.test(seg) && !/\.(git|atom)$/i.test(seg);
|
|
65
|
+
}
|
|
66
|
+
/** A single GitLab group or username -- one segment, no slash. */
|
|
67
|
+
export function validateGitlabNamespace(value, label = 'GitLab group/username') {
|
|
68
|
+
if (!validGitlabSegment(value)) {
|
|
69
|
+
fail([
|
|
70
|
+
`Error: ${label} "${value}" is not a valid GitLab namespace.`,
|
|
71
|
+
' Expected a single path segment of letters, digits, dots, underscores, and hyphens.',
|
|
72
|
+
' Use --global with just the group name, not a full project path.',
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A full GitLab project path, which may be nested: `group/subgroup/project`.
|
|
79
|
+
*
|
|
80
|
+
* Slashes are legal here, unlike a GitHub repo name, so this cannot reuse the
|
|
81
|
+
* GitHub validator. Every segment is checked individually; empty segments (from
|
|
82
|
+
* a leading, trailing, or doubled slash) are rejected because they silently
|
|
83
|
+
* change the project_path sub claim.
|
|
84
|
+
*/
|
|
85
|
+
export function validateGitlabProjectPath(value, label = 'GitLab project path') {
|
|
86
|
+
const segments = value.split('/');
|
|
87
|
+
if (segments.length < 2 || !segments.every(validGitlabSegment)) {
|
|
88
|
+
fail([
|
|
89
|
+
`Error: ${label} "${value}" is not a valid GitLab project path.`,
|
|
90
|
+
' Expected group/project, optionally nested as group/subgroup/project.',
|
|
91
|
+
' Each segment may contain letters, digits, dots, underscores, and hyphens.',
|
|
92
|
+
]);
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Normalizes a GitLab instance URL and returns the URL and its bare hostname.
|
|
98
|
+
*
|
|
99
|
+
* The hostname is used two ways that both break silently on a malformed value:
|
|
100
|
+
* as the last element of the OIDC provider ARN, and as the prefix of the
|
|
101
|
+
* `<host>:aud` / `<host>:sub` trust policy condition keys. Deriving it with a
|
|
102
|
+
* bare `.replace(/^https?:\/\//, '')` leaves any trailing slash or path in
|
|
103
|
+
* place, so `https://gitlab.com/` yields the condition key `gitlab.com/:sub`,
|
|
104
|
+
* which no token will ever match -- the role simply becomes unassumable, with
|
|
105
|
+
* no error at creation time.
|
|
106
|
+
*/
|
|
107
|
+
export function normalizeGitlabUrl(value, label = 'GitLab instance URL') {
|
|
108
|
+
let parsed;
|
|
109
|
+
try {
|
|
110
|
+
parsed = new URL(value);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return fail([
|
|
114
|
+
`Error: ${label} "${value}" is not a valid URL.`,
|
|
115
|
+
' Expected something like https://gitlab.com or https://gitlab.example.com.',
|
|
116
|
+
]);
|
|
117
|
+
}
|
|
118
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
119
|
+
fail([`Error: ${label} must use http or https, got "${parsed.protocol}".`]);
|
|
120
|
+
}
|
|
121
|
+
if (parsed.pathname !== '/' && parsed.pathname !== '') {
|
|
122
|
+
fail([
|
|
123
|
+
`Error: ${label} "${value}" must not include a path.`,
|
|
124
|
+
` Use the instance root, e.g. ${parsed.protocol}//${parsed.host}`,
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
// GitLab's aud claim is the instance URL with no trailing slash.
|
|
128
|
+
return { url: `${parsed.protocol}//${parsed.host}`, host: parsed.host };
|
|
129
|
+
}
|
|
130
|
+
// ---- Shared ----
|
|
131
|
+
/**
|
|
132
|
+
* A provider-assigned numeric id (GitHub owner/repo id, GitLab project id).
|
|
133
|
+
*
|
|
134
|
+
* These reach an IAM trust policy sub claim. A non-numeric value cannot be a
|
|
135
|
+
* real id, and permitting one risks widening the claim rather than failing.
|
|
136
|
+
*/
|
|
137
|
+
export function validateNumericId(value, label = 'ID') {
|
|
138
|
+
if (!/^\d+$/.test(value)) {
|
|
139
|
+
fail([`Error: ${label} "${value}" is not numeric.`]);
|
|
140
|
+
}
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@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