Scope pentests by repo on Console V2; deprecate projectId#12
Open
jorgeraad wants to merge 2 commits into
Open
Conversation
Console V2 folded projects into workspaces. /ci/dispatch now scopes by workspace (from the API key) plus an optional repository (repoId = GITHUB_REPOSITORY_ID); projectId is accepted but ignored. dispatchScan let a (now-ignored) projectId shadow repoId, so every documented setup — which sets PENSAR_PROJECT_ID — dropped the auto-detected repoId and produced an unscoped, workspace-wide scan. - Always send repoId when present; send projectId only as a no-op fallback for older Console deployments. - Drop the projectId/repoId requirement: an API key alone resolves to a workspace (workspace-wide scan). - Reframe docs/help/examples around workspace + repository; mark --project / PENSAR_PROJECT_ID deprecated. Bump CLI version string to match package (2.4.0). Closes pensarai#11
Add a framework-free assert check (npm test) that stubs fetch and verifies dispatchScan sends repoId even when projectId is set, and that an identifier-less call no longer throws. Tighten inline comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #11.
Problem
Console V2 folded the
projectsconcept into workspaces./ci/dispatchnow scopes a scan by workspace (from the API key) plus an optional repository (repoId=GITHUB_REPOSITORY_ID, resolved toexternalRepoId);projectIdis accepted but ignored.dispatchScanlet the now-ignoredprojectIdshadowrepoId:Every documented setup sets
PENSAR_PROJECT_ID, soprojectIdwas truthy and the auto-detectedrepoIdwas dropped — producing an unscoped, workspace-wide scan. Workspaces with more than one repo got scanned (and billed) in full; repo-scoping was unreachable from the CLI.Changes
src/lib/ci.ts— always sendrepoIdwhen present; sendprojectIdonly as a no-op fallback for older Console deployments. Drop theprojectId || repoIdrequirement (an API key alone resolves to a workspace → workspace-wide scan). Prefer the repo in the dispatch log line.--project/PENSAR_PROJECT_IDdeprecated. UpdatedREADME.md,examples/README.md,src/bin/index.tshelp text, and bumped the CLI version string1.2.0 → 2.4.0to matchpackage.json.examples/**— dropPENSAR_PROJECT_ID. GitHub Actions auto-detects the repo; GitLab has no GitHub repo id, so its jobs run workspace-wide (documented; pass--repo-idto scope).assertcheck (npm test) that stubsfetchand verifiesdispatchScansendsrepoIdeven whenprojectIdis set, and that an identifier-less call no longer throws. Guards the exact regression this PR fixes.Verification
npm testpasses;tscbuild clean.packages/functions/src/ci/dispatch.ts+status.tsand their tests in Console (.strict()schema explicitly allow-listsprojectId/repoId/repositoryId/workspaceId).GitLab repo-scoping (mapping
CI_PROJECT_ID→ repository) is out of scope here.