8000 add options: accept-key by tomoyamachi · Pull Request #149 · goodwithtech/dockle · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add options: accept-key #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/dockle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ OPTIONS:
Name: "ignore, i",
Usage: "checkpoints to ignore. You can use .dockleignore too.",
},
cli.StringSliceFlag{
Name: "accept-key, a",
EnvVar: "ACCEPT_KEY",
Usage: "For CIS-DI-0010. You can add acceptable keywords. e.g) -a GPG_KEY -a KEYCLOAK",
},
cli.StringFlag{
Name: "format, f",
Value: "",
Expand Down
8 changes: 7 additions & 1 deletion pkg/assessor/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func (a ManifestAssessor) Assess(fileMap deckodertypes.FileMap) (assesses []*typ
return checkAssessments(d)
}

func AddAcceptanceKeys(keys []string) {
for _, key := range keys {
acceptanceEnvKey[key] = struct{}{}
}
}

func checkAssessments(img types.Image) (assesses []*types.Assessment, err error) {
if img.Config.User == "" || img.Config.User == "root" {
assesses = append(assesses, &types.Assessment{
Expand All @@ -61,7 +67,7 @@ func checkAssessments(img types.Image) (assesses []*types.Assessment, err error)
assesses = append(assesses, &types.Assessment{
Code: types.AvoidCredential,
Filename: ConfigFileName,
Desc: fmt.Sprintf("Suspicious ENV key found : %s", envKey),
Desc: fmt.Sprintf("Suspicious ENV key found : %s (You can suppress it with --accept-key)", envKey),
})
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/goodwithtech/dockle/pkg/assessor/manifest"
l "log"
"os"
"strings"
Expand Down Expand Up @@ -72,8 +73,9 @@ func Run(c *cli.Context) (err error) {
return fmt.Errorf("invalid image: %w", err)
}
}
log.Logger.Debug("Start assessments...")
manifest.AddAcceptanceKeys(c.StringSlice("accept-key"))

log.Logger.Debug("Start assessments...")
assessments, err := scanner.ScanImage(ctx, imageName, filePath, dockerOption)
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
Expand Down
0