Skip to content

Commit d2d775c

Browse files
frjcompCopilot
andauthored
Improve CLI flags parsing (#624)
* Unify CLI flags usage --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 1d7d1ed commit d2d775c

182 files changed

Lines changed: 5260 additions & 1477 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ make serve-docs # Installs dependencies if needed, generates and serves docs
187187
- Each command should have a corresponding test file
188188
- Commands are organized by platform (gitlab, github, bitbucket, devops, gitea)
189189
- Use consistent flag naming across commands
190-
- **When adding or modifying command flags**: Update both `docs/introduction/configuration.md` and `pipeleek.example.yaml` to reflect the changes
190+
- **When adding or modifying command flags**: Update `docs/introduction/configuration.md` and ensure `pipeleek config gen` output remains accurate
191191

192192
### Configuration Loading Pattern (MANDATORY)
193193

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help build build-all build-gitlab build-github build-bitbucket build-devops build-gitea build-circle test test-unit test-e2e lint clean coverage coverage-html serve-docs
1+
.PHONY: help build build-all build-gitlab build-github build-bitbucket build-devops build-gitea build-circle test test-unit test-e2e lint clean coverage coverage-html serve-docs release-guard
22

33
# Default target
44
help:
@@ -18,6 +18,7 @@ help:
1818
@echo " make test-e2e - Run e2e tests (builds binary first)"
1919
@echo " make coverage - Generate test coverage report"
2020
@echo " make coverage-html - Generate and open HTML coverage report"
21+
@echo " make release-guard - Compare against latest release and run pre-release safety checks"
2122
@echo " make lint - Run golangci-lint"
2223
@echo " make serve-docs - Generate and serve CLI documentation"
2324
@echo " make clean - Remove built artifacts"
@@ -126,6 +127,13 @@ coverage-html: coverage
126127
echo "Open coverage.html in your browser to view the report"; \
127128
fi
128129

130+
# Compare current branch against latest release and run release-safety checks
131+
# Set STRICT_ALLOWLIST=1 to fail if changed files fall outside ALLOWLIST_REGEX.
132+
# Set FAST_MODE=1 to skip gosec and golangci-lint for faster iteration.
133+
release-guard:
134+
@echo "Running pre-release guard..."
135+
./scripts/pre_release_guard.sh
136+
129137
# Run golangci-lint
130138
lint:
131139
@echo "Running golangci-lint..."

docs/guides/gitlab.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Prefer the authenticated scan over the unauthenticated one whenever possible, as
3333

3434
```bash
3535
# Scan all publicly accessible CI/CD logs, including artifacts (breadth-first)
36-
pipeleek gluna scan -g https://leakycompany.com -a --job-limit 10
36+
pipeleek gluna scan -u https://leakycompany.com -a --job-limit 10
3737
```
3838

3939
## Authenticated Access
@@ -55,7 +55,7 @@ Make sure to verify manually as well.
5555
> To create a Personal Access Token visit https://leakycompany.com/-/user_settings/personal_access_tokens
5656
5757
```bash
58-
pipeleek gl vuln -g https://leakycompany.com -t glpat-[redacted]
58+
pipeleek gl vuln -u https://leakycompany.com -t glpat-[redacted]
5959
2024-11-14T14:29:05+01:00 info GitLab version=17.5.1-ee
6060
2024-11-14T14:29:05+01:00 info Fetching CVEs for this version version=17.5.1-ee
6161
```
@@ -68,16 +68,16 @@ Dump all CI/CD variables you have access to, to find more secrets.
6868

6969
```bash
7070
# Dump variables defined in the projects settings
71-
pipeleek gl variables -g https://leakycompany.com -t glpat-[redacted]
71+
pipeleek gl variables -u https://leakycompany.com -t glpat-[redacted]
7272

7373
# Schedules can have separately defined variables
74-
pipeleek gl schedule -g https://leakycompany.com -t glpat-[redacted]
74+
pipeleek gl schedule -u https://leakycompany.com -t glpat-[redacted]
7575

7676
# Secure files are an alternative to variables and often times contain sensitive info
77-
pipeleek gl secureFiles -g https://leakycompany.com -t glpat-[redacted]
77+
pipeleek gl secureFiles -u https://leakycompany.com -t glpat-[redacted]
7878

7979
# Terraform states can contain secrets
80-
pipeleek gl tf --token -g https://leakycompany.com -t glpat-[redacted]
80+
pipeleek gl tf -u https://leakycompany.com -t glpat-[redacted]
8181
```
8282

8383
## Secret Detection in Source Code
@@ -158,7 +158,7 @@ There are many reasons why credentials might be included in the job output. More
158158
[Pipeleek](https://github.com/CompassSecurity/pipeleek) can be used to scan for credentials in the job outputs.
159159

160160
```bash
161-
$ pipeleek gl scan --token glpat-[redacted] --gitlab https://gitlab.example.com -c [gitlab session cookie]] -v -a -j 5 --confidence high-verified,high
161+
$ pipeleek gl scan --token glpat-[redacted] --url https://gitlab.example.com -c [gitlab session cookie]] -v -a -j 5 --confidence high-verified,high
162162
2024-09-26T13:47:09+02:00 debug Verbose log output enabled
163163
2024-09-26T13:47:10+02:00 info Gitlab Version Check revision=2e166256199 version=17.5.0-pre
164164
2024-09-26T13:47:10+02:00 debug Setting up queue on disk
@@ -209,7 +209,7 @@ curl --request GET --header "PRIVATE-TOKEN: glpat-[redacted]" https://gitlab.exa
209209
}
210210

211211
# Verify using Pipeleek
212-
pipeleek gl enum -g https://gitlab.example.com -t glpat-[redacted]
212+
pipeleek gl enum -u https://gitlab.example.com -t glpat-[redacted]
213213
2025-09-29T12:25:51Z info Enumerating User
214214
2025-09-29T12:25:51Z warn Current user admin=false bot=false email=test@example.com name="Pipe Leak" username=pipeleek_user
215215
2025-09-29T12:25:51Z info Enumerating Access Token
@@ -236,7 +236,7 @@ Runners can be attached globally, on the group level or on individual projects.
236236
Using pipeleek we can automate runner enumeration:
237237

238238
```bash
239-
$ pipeleek gl runners --token glpat-[redacted] --gitlab https://gitlab.example.com -v list
239+
$ pipeleek gl runners --token glpat-[redacted] --url https://gitlab.example.com -v list
240240
2024-09-26T14:26:54+02:00 info group runner description=2-green.shared-gitlab-org.runners-manager.gitlab.example.com name=comp-test-ia paused=false runner=gitlab-runner tags=gitlab-org type=instance_type
241241
2024-09-26T14:26:55+02:00 info group runner description=3-green.shared-gitlab-org.runners-manager.gitlab.example.com/dind name=comp-test-ia paused=false runner=gitlab-runner tags=gitlab-org-docker type=instance_type
242242
2024-09-26T14:26:55+02:00 info group runner description=blue-3.saas-linux-large-amd64.runners-manager.gitlab.example.com/default name=comp-test-ia paused=false runner=gitlab-runner tags=saas-linux-large-amd64 type=instance_type
@@ -250,7 +250,7 @@ Pipeleek can generate a `.gitlab-ci.yml` or directly create a project and launch
250250

251251
```bash
252252
# Manual creation
253-
$ pipeleek gl runners --token glpat-[redacted] --gitlab https://gitlab.example.com -v exploit --tags saas-linux-small-amd64 --shell --dry
253+
$ pipeleek gl runners --token glpat-[redacted] --url https://gitlab.example.com -v exploit --tags saas-linux-small-amd64 --shell --dry
254254
2024-09-26T14:32:26+02:00 debug Verbose log output enabled
255255
2024-09-26T14:32:26+02:00 info Generated .gitlab-ci.yml
256256
2024-09-26T14:32:26+02:00 info ---
@@ -276,7 +276,7 @@ pipeleek-job-saas-linux-small-amd64:
276276
2024-09-26T14:32:26+02:00 info Done, Bye Bye 🏳️‍🌈🔥
277277

278278
# Automated
279-
$ pipeleek gl runners --token glpat-[redacted] --gitlab https://gitlab.example.com -v exploit --tags saas-linux-small-amd64 --shell
279+
$ pipeleek gl runners --token glpat-[redacted] --url https://gitlab.example.com -v exploit --tags saas-linux-small-amd64 --shell
280280
2024-09-26T14:33:48+02:00 debug Verbose log output enabled
281281
2024-09-26T14:33:49+02:00 info Created project name=pipeleek-runner-exploit url=https://gitlab.example.com/[redacted]/pipeleek-runner-exploit
282282
2024-09-26T14:33:50+02:00 info Created .gitlab-ci.yml file=.gitlab-ci.yml
@@ -415,7 +415,7 @@ docker run --rm --entrypoint sh registry.gitlab.example.com/auser/artipacked:lat
415415
Then validate and create PoC exploit:
416416

417417
```bash
418-
pipeleek gl jobToken exploit --project auser/artipacked --token glcbt-6c_z1CoZjUyFfAu6cE2XFTC
418+
pipeleek gl jobToken exploit --repo auser/artipacked --token glcbt-6c_z1CoZjUyFfAu6cE2XFTC
419419
2026-02-09T15:25:30Z info Job token validation succeeded
420420
2026-02-09T15:25:30Z info Job token context resolved job_id=13042619352 project=auser/artipacked project_id=79339419 ref=main status=running web_url=https://gitlab.example.com/auser/artipacked/-/jobs/13042619352
421421
2026-02-09T15:25:30Z info Fetching secure files project=auser/artipacked

docs/guides/renovate.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Use the `enum` command to scan your GitLab instance for Renovate bot jobs and co
3535
For example, we enumerated Renovate configs found on GitLab.com. One project was found that enables Renovate's autodiscovery of projects and does **not** set any autodiscovery filters.
3636

3737
```bash
38-
pipeleek gl renovate enum -g https://gitlab.com -t glpat-[redacted] --dump
38+
pipeleek gl renovate enum -u https://gitlab.com -t glpat-[redacted] --dump
3939
2025-09-30T07:11:06Z info Fetching projects
4040
2025-09-30T07:11:12Z warn Identified Renovate (bot) configuration autodiscoveryFilterType= autodiscoveryFilterValue= hasAutodiscovery=true hasAutodiscoveryFilters=false hasConfigFile=true pipelines=enabled selfHostedConfigFile=true url=https://gitlab.com/test-group/renovate-bot
4141
2025-09-30T07:11:16Z info Fetched all projects
@@ -53,7 +53,7 @@ The Renovate bot from the example above is configured to autodiscover new projec
5353
The following command creates a repository that includes an exploit script called `exploit.sh`. Whenever a Renovate bot picks up this repo, the script will be executed.
5454

5555
```bash
56-
pipeleek gl renovate autodiscovery -g https://gitlab.com -t glpat-[redacted] -v
56+
pipeleek gl renovate autodiscovery -u https://gitlab.com -t glpat-[redacted] -v
5757
2025-09-30T07:19:33Z info Created project name=devfe-pipeleek-renovate-autodiscovery-poc url=https://gitlab.com/myuser/devfe-pipeleek-renovate-autodiscovery-poc
5858
2025-09-30T07:19:35Z debug Created file fileName=renovate.json
5959
2025-09-30T07:19:35Z debug Created file fileName=pom.xml
@@ -112,6 +112,7 @@ In that file, extract all sensitive environment variables and use them for later
112112
> After receiving a merge request from the Renovate bot, you must fully delete both the branch and the merge request. This ensures the bot will recreate them, allowing your script to run again. Otherwise, the script will not be executed a second time. Ensure to revert the commits as well if they were merged.
113113
114114
### Dump Renovate Process Heap
115+
115116
In some cases the Renovate bot configuration file might have been [deleted](https://docs.renovatebot.com/self-hosted-configuration/#deleteconfigfile) and you want to recover it. The following script can be used to dump the heap for further analysis.
116117
117118
```bash
@@ -174,7 +175,7 @@ Your goal is to abuse the Renovate bot's access level to merge a malicious `gitl
174175
Using Pipeleek, you can monitor your repository for new Renovate branches. When a new one is detected, Pipeleek tries to add a new job into the `gitlab-ci.yml`. As this needs to exploit a race condition (adding new changes to the Renovate branch before the bot activates auto-merge), this might take a few attempts.
175176
176177
```bash
177-
pipeleek gl renovate privesc -g https://gitlab.com -t glpat-[redacted] --repo-name company1/a-software-project --renovate-branches-regex 'renovate/.*' -v
178+
pipeleek gl renovate privesc -u https://gitlab.com -t glpat-[redacted] --repo company1/a-software-project --renovate-branches-regex 'renovate/.*' -v
178179
2025-09-30T07:56:57Z debug Verbose log output enabled
179180
2025-09-30T07:56:57Z info Ensure the Renovate bot does have a greater access level than you, otherwise this will not work, and is able to auto merge into the protected main branch
180181
2025-09-30T07:56:58Z debug Testing push access level for default branch branch=main requiredAccessLevel=40 userAccessLevel=30

docs/guides/scanning.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Start by creating a personal access token (`Menu` → `Preferences` → `Access
2020
For an initial scan, target all repositories you can access, including public ones. To keep the scan fast and broad, limit it to the latest 15 jobs per project:
2121

2222
```bash
23-
pipeleek gl scan -g https://gitlab.com -t glpat-[redacted] --cookie [redacted] --artifacts --job-limit 15
23+
pipeleek gl scan -u https://gitlab.com -t glpat-[redacted] --cookie [redacted] --artifacts --job-limit 15
2424
2025-09-30T09:53:30Z info Gitlab Version Check revision=f0455ea9f90 version=18.5.0-pre
2525
2025-09-30T09:53:30Z info Fetching projects
2626
2025-09-30T09:53:30Z info Provided GitLab session cookie is valid
@@ -34,5 +34,5 @@ As shown, Pipeleek can detect secrets in job logs and build artifacts. Security
3434
If you find a repository that looks particularly interesting e.g. `secret-pipelines`, you can scan all its job logs, not just the most recent ones:
3535

3636
```bash
37-
pipeleek gl scan -g https://gitlab.com -t glpat-[redacted] --cookie [redacted] --artifacts --repo mygroup/my-secret-pipelines-project
37+
pipeleek gl scan -u https://gitlab.com -t glpat-[redacted] --cookie [redacted] --artifacts --repo mygroup/my-secret-pipelines-project
3838
```

0 commit comments

Comments
 (0)