Skip to content

feat(secrets): add launch:secrets list, set and unset commands - #268

Open
tejas-contentstack wants to merge 6 commits into
developmentfrom
CL-8166
Open

tejas-contentstack wants to merge 6 commits into
developmentfrom
CL-8166

Conversation

@tejas-contentstack

@tejas-contentstack tejas-contentstack commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Opened by launch-developer-agent (Claude). Replies from this account are the AI agent too. Review stays human. Merge: by this agent once one human approves, with no changes requested and green checks.

Jira: https://contentstack.atlassian.net/browse/CL-8166

Changes

Adds csdx launch:secrets:list, launch:secrets:set and launch:secrets:unset on the existing GraphQL client (Environment.secrets, add/refresh/deleteEnvironmentSecret). list prints only KEY and UPDATED. set takes the value from a masked prompt or piped stdin (no --value flag), adds or refreshes after confirming (--yes for CI), and warns on client-exposed prefixes. unset takes repeatable --key. A secret value never reaches output, logs or errors; API errors (409, 400, 403, 404) get clear messages.

Testing Plan

  • npm run test:jest -- src/commands/launch/secrets src/util/secrets.test.ts and npm run test:integration: pass. Test plan: 36/36 scenarios covered (T1–T29 plus review-round regressions).
  • npm run build, tsc --noEmit, eslint on changed files: pass.
  • QA: the Launch QA agent tests CL-8166 in the repos once it is in QA; GoCD sanity covers dev11. A manual set/list/unset check against dev11 is requested from tejas (needs CL-8158/CL-8160 deployed).

Known Gaps

  • Repo-wide npm run test:unit shows 24 mocha failures (not logged in) and eslint 103 errors; both are identical on development.
  • Snyk could not run locally (token rejected); CI runs it. Commits used --no-verify as approved by tejas after running lint-staged, Talisman and TruffleHog by hand; .talismanrc checksums were refreshed (only "secret" wording flagged).
  • README/oclif manifest not regenerated; set has a hidden --branch flag for piped use.

Merge order: independent of the other PRs on this story.


Generated by Claude Code

@tejas-contentstack
tejas-contentstack marked this pull request as ready for review October 29, 2026 18:59
@tejas-contentstack
tejas-contentstack requested a review from a team as a code owner October 29, 2026 18:59
@snyk-io

snyk-io Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 10 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 10
  • Medium without fixes: 2
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 10 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 10
  • Medium without fixes: 2
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

Comment thread src/graphql/mutation.ts Resolved
Comment thread src/graphql/mutation.ts Resolved
Comment thread src/util/secrets.ts Resolved
Comment thread src/commands/launch/secrets/set.ts Resolved
Comment thread src/commands/launch/secrets/set.ts Resolved
Comment thread src/commands/launch/secrets/set.ts Resolved
Comment thread src/commands/launch/secrets/set.ts Resolved
Comment thread src/commands/launch/secrets/unset.ts Resolved
Comment thread src/util/secrets.ts Resolved
Comment thread src/commands/launch/secrets/set.ts Resolved

@tejas-contentstack tejas-contentstack left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A high-effort review found 10 issues, which are posted as inline comments. Not approved for two reasons: there are findings, and the PR was opened by the account this review runs as.

The most important problem is that the GraphQL mutations don't match the management-service schema. add/refresh/deleteEnvironmentSecret expect environment: EnvironmentInput! and secret: …Input!, not environmentUid: String!/key. As a result, secrets:set and secrets:unset will fail against the real API. Also, formatSecretsError matches enum names, but the server sends enum values.


— 🤖 Claude review (Opus 5.5, high effort)


Generated by Claude Code

@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 10 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 10
  • Medium without fixes: 2
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

Copy link
Copy Markdown
Contributor Author

Addressed all 10 review comments in 51fe75b and 18420d1 (scoped jest, the full integration suite and the build pass). One partial: undefined isTTY, see that thread.

— 🤖 launch-developer-agent (Claude)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EptZEgdDeWAT9sPWVLu9z2


Generated by Claude Code

@Harshi-Shah-CS Harshi-Shah-CS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change the commit title to follow cli convention
of semantic message and avoid adding +claude in pr title

@tejas-contentstack tejas-contentstack changed the title CL-8166 | +Claude | Manage secrets from the Launch CLI feat(secrets): add launch:secrets list, set and unset commands Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Retitled the PR to follow the CLI's Conventional Commits style (no +Claude). Rewording the six commit subjects the same way needs a history rewrite of this branch (I have them ready locally, rebased on the latest development, code unchanged); I'm holding that until the owner approves a force-push. If the PR is squash-merged, the PR title becomes the commit title.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EptZEgdDeWAT9sPWVLu9z2


Generated by Claude Code

Add csdx launch:secrets:list with --org, --project and --environment
flags. It reads Environment.secrets (key and updatedAt only) through
the existing GraphQL client and renders a KEY / UPDATED table, never a
value. A 403 shows a clear permission message. Refreshed .talismanrc
checksums for the touched files (only "secret" wording flagged).

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add csdx launch:secrets:set, which reads the value from a masked prompt
or piped stdin (no --value flag), adds or refreshes the secret after
confirmation, warns on client-exposed prefixes and redacts values from
errors. Adds the shared secrets util and the add/refresh mutations.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Delete one or more environment secrets with a repeatable --key, after a
confirmation unless --yes is passed. A failing key is reported by name
and the remaining keys are still deleted, with exit 1 at the end.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Read a piped secret from stdin before getConfig and any org, project,
environment or branch prompt, and require --org, --project and
--environment when piping. Redact whole flag values (spaced and short
form) from parse errors, and format every list query failure instead of
rethrowing the raw error.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…e schema

Send addEnvironmentSecret, refreshEnvironmentSecret and
deleteEnvironmentSecret with the environment and secret input objects
the schema defines, and recognise the real FormError enum values
(status 400) in formatSecretsError. Fixtures and specs now reproduce
the real error shape and assert the exact variables sent.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
… and share scope setup

Move the org, project, branch and environment setup of list, set and
unset into SecretsBaseCommand. Explicit --org and --project now
override the stored project, and when stdin is not a terminal nothing
can prompt: unresolved scope, branch ambiguity and a missing --yes fail
with exit 1. BaseCommand.getConfig gains an opt-in non-interactive mode.
Parse errors no longer echo argv, piped stdin reads are bounded, and
read failures use read-context wording.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 10 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 10
  • Medium without fixes: 2
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@@ -0,0 +1,161 @@
import { print } from 'graphql';
import { randomUUID } from 'crypto';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not going to be merging this with development branch. We'll be using v2-dev as a base branch. make sure not to pollute anything in v2-dev with development branch when you take create another PR with base v2-dev.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood: v2-dev as the base, a new PR, nothing from development carried over. I'll cut CL-8166 from origin/v2-dev and port the three groups once the base is confirmed on the ticket (CL-8166 has no Base branch: line, and its Epic isn't the V2 one). I've left the details on the Jira ticket. This PR stays open until then.

— 🤖 launch-developer-agent (Claude)


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Superseded by #275, which carries the work on v2-dev as asked (REST client, Conventional Commits, nothing from development). Closing this one is yours to decide; I have not closed it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EptZEgdDeWAT9sPWVLu9z2


Generated by Claude Code

@dhruv-parekh-cs dhruv-parekh-cs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the whole PR: 0 high, 1 medium (cross-repo, below).

Cross-repo (CL-8166): Medium #275 replaces this PR (rebuilt on v2-dev at the ticket owner's request), per the dev agent's post. Merging this one into development would ship a second, GraphQL-based implementation of the same launch:secrets commands. Close it, or say why both should land.

— 🤖 launch-pr-review-agent (Claude)


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂ Proxy