Skip to content

Commit a9c8797

Browse files
committed
Normalize git-type
Signed-off-by: Patrick <[email protected]>
1 parent 32466b1 commit a9c8797

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

scanners/git-repo-scanner/docs/README.ArtifactHub.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ repository type with the option:
6161
```bash
6262
--git-type github
6363
or
64-
--git-type Gitlab
64+
--git-type gitlab
6565
```
6666

6767
#### GitHub
@@ -168,4 +168,3 @@ Code of secureCodeBox is licensed under the [Apache License 2.0][scb-license].
168168
[scb-mastodon]: https://infosec.exchange/@secureCodeBox
169169
[scb-slack]: https://owasp.org/slack/invite
170170
[scb-license]: https://github.com/secureCodeBox/secureCodeBox/blob/master/LICENSE
171-

scanners/git-repo-scanner/docs/README.DockerHub-Scanner.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ repository type with the option:
6464
```bash
6565
--git-type github
6666
or
67-
--git-type Gitlab
67+
--git-type gitlab
6868
```
6969

7070
#### GitHub
@@ -124,4 +124,3 @@ As for any pre-built image usage, it is the image user's responsibility to ensur
124124
[scb-mastodon]: https://infosec.exchange/@secureCodeBox
125125
[scb-slack]: https://owasp.org/slack/invite
126126
[scb-license]: https://github.com/secureCodeBox/secureCodeBox/blob/master/LICENSE
127-

scanners/git-repo-scanner/examples/github-secureCodeBox-scan/scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
scanType: "git-repo-scanner"
1111
parameters:
1212
- "--git-type"
13-
- "GitHub"
13+
- "github"
1414
- "--organization"
1515
- "secureCodeBox"
1616
cascades:

scanners/git-repo-scanner/examples/gitlab-group-scan/scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
scanType: "git-repo-scanner"
1111
parameters:
1212
- "--git-type"
13-
- "GitLab"
13+
- "gitlab"
1414
- "--url"
1515
- "https://gitlab.your-company.com"
1616
- "--access-token"

scanners/git-repo-scanner/integration-tests/git-repo-scanner.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test.skip(
1212
const { count } = await scan(
1313
"git-repo-scanner-dummy-scan",
1414
"git-repo-scanner",
15-
["--git-type", "GitHub", "--organization", "secureCodeBox"],
15+
["--git-type", "github", "--organization", "secureCodeBox"],
1616
);
1717
// There must be >= 28 Repositories found in the GitHub secureCodeBox organisation.
1818
expect(count).toBeGreaterThanOrEqual(28);

scanners/git-repo-scanner/scanner/internal/config/config.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ func ParseFlags(logger *log.Logger) (*Config, error) {
6363

6464
flag.Parse()
6565

66+
config.GitType = normalizeGitType(config.GitType)
67+
6668
if err := config.validate(); err != nil {
6769
flag.Usage()
6870
return nil, err
@@ -75,6 +77,17 @@ func ParseFlags(logger *log.Logger) (*Config, error) {
7577
return config, nil
7678
}
7779

80+
func normalizeGitType(gitType string) string {
81+
switch strings.ToLower(gitType) {
82+
case "github":
83+
return "GitHub"
84+
case "gitlab":
85+
return "GitLab"
86+
default:
87+
return gitType
88+
}
89+
}
90+
7891
func (c *Config) validate() error {
7992
if c.GitType == "" {
8093
return fmt.Errorf("--git-type is required")

0 commit comments

Comments
 (0)