Skip to content

Commit

Permalink
added member filter option
Browse files Browse the repository at this point in the history
  • Loading branch information
frjcomp committed Aug 12, 2024
1 parent 870907f commit 6ae2dcd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:

jobs:
release-platforms:
name: release linux/amd64
name: release builds
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Filter the scanned projects by using the `--search` flag and provide a search qu

Filter the scanned projects by using the `--owned` flag to only process projects owned by you.

Filter the scanned projects by using the `--member` flag to only process projects you are a member of.

Limit the scanned nr of jobs by using the `--job-limit` flag.

## Customizing Scan Rules
Expand Down
10 changes: 6 additions & 4 deletions src/pipeleak/cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
projectSearchQuery string
artifacts bool
owned bool
member bool
jobLimit int
verbose bool
)
Expand Down Expand Up @@ -44,11 +45,12 @@ func NewScanCmd() *cobra.Command {
scanCmd.Flags().StringVarP(&gitlabCookie, "cookie", "c", "", "GitLab Cookie _gitlab_session (must be extracted from your browser, use remember me)")
scanCmd.Flags().StringVarP(&projectSearchQuery, "search", "s", "", "Query string for searching projects")

scanCmd.PersistentFlags().BoolVarP(&artifacts, "artifacts", "a", false, "Scan Job Artifacts")
scanCmd.PersistentFlags().BoolVarP(&owned, "owned", "o", false, "Scan Onwed Projects Only")
scanCmd.PersistentFlags().BoolVarP(&artifacts, "artifacts", "a", false, "Scan job artifacts")
scanCmd.PersistentFlags().BoolVarP(&owned, "owned", "o", false, "Scan user onwed projects only")
scanCmd.PersistentFlags().BoolVarP(&member, "member", "m", false, "Scan projects the user is member of")
scanCmd.PersistentFlags().IntVarP(&jobLimit, "job-limit", "j", 0, "Scan a max number of pipeline jobs - trade speed vs coverage. 0 scans all and is the default.")

scanCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose Logging")
scanCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Verbose logging")

return scanCmd
}
Expand All @@ -62,7 +64,7 @@ func Scan(cmd *cobra.Command, args []string) {
os.Exit(1)
}

scanner.ScanGitLabPipelines(gitlabUrl, gitlabApiToken, gitlabCookie, artifacts, owned, projectSearchQuery, jobLimit)
scanner.ScanGitLabPipelines(gitlabUrl, gitlabApiToken, gitlabCookie, artifacts, owned, projectSearchQuery, jobLimit, member)
}

func setLogLevel() {
Expand Down
9 changes: 5 additions & 4 deletions src/pipeleak/scanner/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/xanzy/go-gitlab"
)

func ScanGitLabPipelines(gitlabUrl string, apiToken string, cookie string, scanArtifacts bool, scanOwnedOnly bool, query string, jobLimit int) {
func ScanGitLabPipelines(gitlabUrl string, apiToken string, cookie string, scanArtifacts bool, scanOwnedOnly bool, query string, jobLimit int, member bool) {
log.Info().Msg("Fetching projects")
git, err := gitlab.NewClient(apiToken, gitlab.WithBaseURL(gitlabUrl))
if err != nil {
Expand All @@ -30,9 +30,10 @@ func ScanGitLabPipelines(gitlabUrl string, apiToken string, cookie string, scanA
PerPage: 100,
Page: 1,
},
Owned: gitlab.Ptr(scanOwnedOnly),
Search: gitlab.Ptr(query),
OrderBy: gitlab.Ptr("last_activity_at"),
Owned: gitlab.Ptr(scanOwnedOnly),
Membership: gitlab.Ptr(member),
Search: gitlab.Ptr(query),
OrderBy: gitlab.Ptr("last_activity_at"),
}

for {
Expand Down

0 comments on commit 6ae2dcd

Please sign in to comment.