Skip to content

Commit c137ab7

Browse files
authored
Merge pull request #123 from CompassSecurity/refactor-platform-pattern
Refactor Platform Pattern
2 parents b05dc01 + 377562c commit c137ab7

20 files changed

+716
-123
lines changed

docs/demo.ipynb

+8-8
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"metadata": {},
7474
"outputs": [],
7575
"source": [
76-
"!/tmp/pipeleak scan --gitlab https://gitlab.com -t $GITLAB_PAT --owned --search 'secret-pipeline' --job-limit 10 --confidence high-verified"
76+
"!/tmp/pipeleak gl scan --gitlab https://gitlab.com -t $GITLAB_PAT --owned --search 'secret-pipeline' --job-limit 10 --confidence high-verified"
7777
]
7878
},
7979
{
@@ -93,7 +93,7 @@
9393
"metadata": {},
9494
"outputs": [],
9595
"source": [
96-
"!/tmp/pipeleak scan --gitlab https://gitlab.com -t $GITLAB_PAT --owned --search 'secret-pipeline' --job-limit 10 --confidence high --artifacts"
96+
"!/tmp/pipeleak gl scan --gitlab https://gitlab.com -t $GITLAB_PAT --owned --search 'secret-pipeline' --job-limit 10 --confidence high --artifacts"
9797
]
9898
},
9999
{
@@ -118,7 +118,7 @@
118118
"metadata": {},
119119
"outputs": [],
120120
"source": [
121-
"!/tmp/pipeleak scan --gitlab https://gitlab.com -t $GITLAB_PAT --owned --search 'secret-pipeline' --job-limit 10 --confidence high --artifacts --cookie $GITLAB_COOKIE | grep -i dotenv"
121+
"!/tmp/pipeleak gl scan --gitlab https://gitlab.com -t $GITLAB_PAT --owned --search 'secret-pipeline' --job-limit 10 --confidence high --artifacts --cookie $GITLAB_COOKIE | grep -i dotenv"
122122
]
123123
},
124124
{
@@ -136,7 +136,7 @@
136136
"metadata": {},
137137
"outputs": [],
138138
"source": [
139-
"!/tmp/pipeleak variables --gitlab https://gitlab.com -t $GITLAB_PAT"
139+
"!/tmp/pipeleak gl variables --gitlab https://gitlab.com -t $GITLAB_PAT"
140140
]
141141
},
142142
{
@@ -152,7 +152,7 @@
152152
"metadata": {},
153153
"outputs": [],
154154
"source": [
155-
"!/tmp/pipeleak secureFiles --gitlab https://gitlab.com -t $GITLAB_PAT"
155+
"!/tmp/pipeleak gl secureFiles --gitlab https://gitlab.com -t $GITLAB_PAT"
156156
]
157157
},
158158
{
@@ -172,7 +172,7 @@
172172
"metadata": {},
173173
"outputs": [],
174174
"source": [
175-
"!/tmp/pipeleak vuln --gitlab https://gitlab.com -t $GITLAB_PAT"
175+
"!/tmp/pipeleak gl vuln --gitlab https://gitlab.com -t $GITLAB_PAT"
176176
]
177177
},
178178
{
@@ -192,7 +192,7 @@
192192
"metadata": {},
193193
"outputs": [],
194194
"source": [
195-
"!/tmp/pipeleak runners list --gitlab https://gitlab.com -t $GITLAB_PAT"
195+
"!/tmp/pipeleak gl runners list --gitlab https://gitlab.com -t $GITLAB_PAT"
196196
]
197197
},
198198
{
@@ -208,7 +208,7 @@
208208
"metadata": {},
209209
"outputs": [],
210210
"source": [
211-
"!/tmp/pipeleak runners exploit --gitlab https://gitlab.com -t $GITLAB_PAT --tags 'gitlab-org-docker' --dry"
211+
"!/tmp/pipeleak gl runners exploit --gitlab https://gitlab.com -t $GITLAB_PAT --tags 'gitlab-org-docker' --dry"
212212
]
213213
}
214214
],

readme.md

+40-25
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@
22
<img height="200" src="https://github.com/CompassSecurity/pipeleak/blob/main/docs/logo.png?raw=true">
33
</p>
44

5+
![GitHub Release Build Status](https://github.com/CompassSecurity/pipeleak/actions/workflows/release.yaml/badge.svg?event=release)
6+
![GitHub Release](https://img.shields.io/github/v/release/CompassSecurity/pipeleak)
7+
![GitHub commits since latest release](https://img.shields.io/github/commits-since/CompassSecurity/pipeleak/latest)
8+
59
# Pipeleak
610

7-
Pipeleak is a tool designed to scan GitLab job output logs and artifacts for potential secrets.
11+
Pipeleak is a tool designed to scan CI/CD logs and artifacts for secrets.
12+
13+
It supports the following platforms:
14+
* GitLab
15+
* GitHub
816

917
## Getting Started
1018

1119
To begin using Pipeleak, download the latest binary from the [Releases](https://github.com/CompassSecurity/pipeleak/releases) page.
1220

13-
### Basic Usage
21+
### General Usage
1422

15-
Run the following command to scan your GitLab instance:
23+
Run the following command to scan your e.g. GitLab instance:
1624

1725
```bash
18-
pipeleak scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com
26+
pipeleak gl scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com
1927
```
2028

2129
### Scanning Artifacts
@@ -24,17 +32,8 @@ In addition to logs, Pipeleak can also scan artifacts generated by your pipeline
2432

2533
Note: Scanning artifacts uses a lot of memory!
2634
```bash
27-
pipeleak scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com -a
28-
```
29-
30-
**Pro tip:**
31-
32-
> Note: [Dotenv artifacts](https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportsdotenv) are not accessible through the GitLab API. To scan these, you need to manually provide your session cookie after logging in via a web browser. The session cookie name is `_gitlab_session`. The cookie should be valid for [two weeks](https://gitlab.com/gitlab-org/gitlab/-/issues/395038).
33-
34-
```bash
35-
pipeleak scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com -v -a -c [value-of-valid-_gitlab_session]
35+
pipeleak gl scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com -a
3636
```
37-
3837
### Confidence
3938

4039
The following confidence levels for scans are used by default:
@@ -46,7 +45,27 @@ The following confidence levels for scans are used by default:
4645
However if you want to add custom ones, you can define any value in the `rules.yml` file
4746
To scan only for a specific level, you can specify it via CLI flag e.g `--confidence=high,medium`. Define multiple by comma separating the values.
4847

49-
Note: `high-verified` cannot be removed.
48+
Note: `high-verified` cannot be removed, but verification can be disabled using `--truffleHogVerification=false`.
49+
50+
### Customizing Scan Rules
51+
52+
When you run Pipeleak for the first time, it generates a `rules.yml` file based on [this repository](https://github.com/mazen160/secrets-patterns-db/blob/master/db/rules-stable.yml). You can customize your scan rules by modifying this file as needed.
53+
54+
### Keybindings
55+
56+
In the `scan` mode you can change interactively between log levels by pressing `t`: Trace, `d`: Debug, `i`: Info, `w`: Warn, `e`: Error. Pressing `s` will output the current queue status.
57+
58+
# Platform Specific Hints
59+
60+
## GitLab
61+
62+
### Dotenv
63+
64+
[Dotenv artifacts](https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportsdotenv) are not accessible through the GitLab API. To scan these, you need to manually provide your session cookie after logging in via a web browser. The session cookie name is `_gitlab_session`. The cookie should be valid for [two weeks](https://gitlab.com/gitlab-org/gitlab/-/issues/395038).
65+
66+
```bash
67+
pipeleak gl scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com -v -a -c [value-of-valid-_gitlab_session]
68+
```
5069

5170
### Memory Usage
5271

@@ -71,30 +90,26 @@ You can tweak `--threads`, `--max-artifact-size` and `--job-limit` to obtain a c
7190

7291
Setting an HTTP proxy is possible by setting the environment variable `HTTP_PROXY` e.g. to route through Burp:
7392
```bash
74-
HTTP_PROXY=http://127.0.0.1:8080 pipeleak scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com
93+
HTTP_PROXY=http://127.0.0.1:8080 pipeleak gl scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com
7594
```
7695

77-
### Keybindings
96+
## GitHub
7897

79-
In the `scan` mode you can change interactively between log levels by pressing `t`: Trace, `d`: Debug, `i`: Info, `w`: Warn, `e`: Error. Pressing `s` will output the current queue status.
98+
No remarks yet 🌟
8099

81-
## ELK Integration
100+
# ELK Integration
82101

83102
To easily analyze the results you can [redirect the pipeleak](https://github.com/deviantony/docker-elk?tab=readme-ov-file#injecting-data) output using `nc` into Logstash.
84103

85104
Setup a local ELK stack using https://github.com/deviantony/docker-elk.
86105

87106
Then you can start a scan:
88107
```bash
89-
pipeleak scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com --json | nc -q0 localhost 50000
108+
pipeleak gl scan --token glpat-xxxxxxxxxxx --gitlab https://gitlab.com --json | nc -q0 localhost 50000
90109
```
91110

92111
Using Kibana you can filter for interesting messages, based on the JSON attributes of the output.
93112

94113
e.g. `message.level=warn and message.confidence=verified` to find verified results.
95114

96-
![Kiabana Search](docs/kibana.png)
97-
98-
## Customizing Scan Rules
99-
100-
When you run Pipeleak for the first time, it generates a `rules.yml` file based on [this repository](https://github.com/mazen160/secrets-patterns-db/blob/master/db/rules-stable.yml). You can customize your scan rules by modifying this file as needed.
115+
![Kiabana Search](docs/kibana.png)

src/pipeleak/cmd/github/github.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package github
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
func NewGitHubRootCmd() *cobra.Command {
8+
ghCmd := &cobra.Command{
9+
Use: "gh [command]",
10+
Short: "GitHub related commands",
11+
}
12+
13+
ghCmd.AddCommand(NewScanCmd())
14+
15+
return ghCmd
16+
}

0 commit comments

Comments
 (0)