Skip to content

test: make the proxy and unreadable-file tests independent of the environment - #309

Merged
chhavi-mandowara-cstk merged 2 commits into
v2-devfrom
test/sandbox-env-isolation
Nov 26, 2026
Merged

chhavi-mandowara-cstk merged 2 commits into
v2-devfrom
test/sandbox-env-isolation

Conversation

@chhavi-mandowara-cstk

@chhavi-mandowara-cstk chhavi-mandowara-cstk commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Why

The pre-push hook runs the full suite. Every Claude cloud routine runs as root behind a proxy that sets a lowercase https_proxy. Three routine sessions checked this on v2-dev cc645ef, and all three saw the same 6 tests fail with no code change. Pushes from those environments could only get through with --no-verify, which skips the whole suite. This PR makes the 6 tests independent of the environment without weakening any assertion.

What

Proxy tests (4): src/transport/errors.test.ts, src/transport/rest-client.test.ts

  • They test the "no proxy configured" message of diagnoseTransportError() ("Could not reach the Launch API (…)"), and the same message from RestApiClient after retries.
  • Their setup cleared only HTTPS_PROXY and HTTP_PROXY. environmentProxy() in src/transport/proxy.ts also reads https_proxy and http_proxy, so with the lowercase form set, the code (correctly) took the proxy branch.
  • The setup now clears and restores all four variables. The assertions are unchanged. The proxy branch stays covered by the existing explains %s as a proxy failure when a proxy is configured tests.

Unreadable-file tests (2): src/uploads/upload.archive.test.ts

  • They test that archiveDirectory() turns a read or listing failure into UsageError (exit 2), naming the path and saying "cannot be read", through readable().
  • They made the failure with chmod 000, which root ignores. They now make readFileSync / readdirSync throw EACCES for that one path only. So they run, and can fail, for every user, root or not, and nothing is skipped. They also assert the denied path was actually read.
  • Mutation check: changing readable() to rethrow the raw error turns both tests red.

.talismanrc: refreshed checksums for the two transport test files (test code, no credentials).

No production code changes.

Verification

  • As root with https_proxy set: src/transport + upload.archive.test.ts → 335/335 passed, none skipped. Before: 6 failed.
  • As a non-root user: upload.archive.test.ts 18/18, and src/transport + archive 335/335.
  • Pushed as root with the full pre-commit and pre-push hooks (lint-staged, Talisman, trufflehog, Snyk, full suite), no --no-verify.

Jira: https://contentstack.atlassian.net/browse/CL-8970 (found while pushing its gap 3)

…ironment

The transport tests cleared HTTPS_PROXY and HTTP_PROXY but not their
lowercase forms, which the proxy resolver also reads, so a shell with
https_proxy set failed four of them. The unreadable-file archive tests rely
on chmod 000 denying access, which root ignores, so they now skip when run
as root.
@snyk-io

snyk-io Bot commented Nov 26, 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 2 25 ✅ Passed
🟡 Medium Severity 0 1 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: 2
  • Medium without fixes: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

The unreadable-file and unreadable-directory tests relied on chmod 000,
which root ignores, so the previous commit skipped them as root. Make
readFileSync and readdirSync throw EACCES for the one path instead, so both
tests run, and can fail, for every user. They assert the denied path was
read and the UsageError the user gets.
@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 2 25 ✅ Passed
🟡 Medium Severity 0 1 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: 2
  • Medium without fixes: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@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.

👍

@chhavi-mandowara-cstk
chhavi-mandowara-cstk merged commit 1d53389 into v2-dev Nov 26, 2026
7 checks passed
@chhavi-mandowara-cstk
chhavi-mandowara-cstk deleted the test/sandbox-env-isolation branch November 26, 2026 09:11
SakshiKoli-CS added a commit that referenced this pull request Nov 26, 2026
…nd add ggshield hooks

Bring v2-dev level with the dependency and hook fixes development already
has, before Launch CLI V2 is promoted to staging. development is not merged
wholesale: most of its 17 missing commits change V1 files that V2 deleted.

- npm audit fix: 10 advisories to 0, all in dev-only packages.
  handlebars 4.7.10 (critical), source-map-js 1.2.4 (high), minimatch
  11.0.9 with typescript-eslint 8.74 and eslint-config-oclif 6.0.179
  (moderate). The only runtime lockfile change is
  @isaacs/nonrecursive-glob-match 1.0.3 -> 1.1.0, within @oclif/core's
  minimatch range.
- @oclif/core range ^4.2.7 -> ^4.14.0 (development #286). The lockfile
  already resolved 4.14.0; it stays on 4.x to match csdx 2.0.2.
- ggshield secret scan in the husky pre-commit and pre-push hooks
  (development e0aad60), without the GitGuardian marker comments.
  pre-push reads the pushed refs once and pipes them to both ggshield and
  the Talisman/trufflehog scan.
- .talismanrc: checksums for both hooks (Talisman flags the setup-URL
  line), a refreshed package.json checksum, and the entry #309 left out
  for src/uploads/upload.archive.test.ts (its secret.txt fixture path
  trips Talisman on every push of a branch rebased onto v2-dev).

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

Co-Authored-By: Claude <noreply@anthropic.com>
SakshiKoli-CS added a commit that referenced this pull request Nov 26, 2026
…nd add ggshield hooks (#310)

Bring v2-dev level with the dependency and hook fixes development already
has, before Launch CLI V2 is promoted to staging. development is not merged
wholesale: most of its 17 missing commits change V1 files that V2 deleted.

- npm audit fix: 10 advisories to 0, all in dev-only packages.
  handlebars 4.7.10 (critical), source-map-js 1.2.4 (high), minimatch
  11.0.9 with typescript-eslint 8.74 and eslint-config-oclif 6.0.179
  (moderate). The only runtime lockfile change is
  @isaacs/nonrecursive-glob-match 1.0.3 -> 1.1.0, within @oclif/core's
  minimatch range.
- @oclif/core range ^4.2.7 -> ^4.14.0 (development #286). The lockfile
  already resolved 4.14.0; it stays on 4.x to match csdx 2.0.2.
- ggshield secret scan in the husky pre-commit and pre-push hooks
  (development e0aad60), without the GitGuardian marker comments.
  pre-push reads the pushed refs once and pipes them to both ggshield and
  the Talisman/trufflehog scan.
- .talismanrc: checksums for both hooks (Talisman flags the setup-URL
  line), a refreshed package.json checksum, and the entry #309 left out
  for src/uploads/upload.archive.test.ts (its secret.txt fixture path
  trips Talisman on every push of a branch rebased onto v2-dev).

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

Co-authored-by: Claude <noreply@anthropic.com>
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