This repository has been archived by the owner on Jun 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aquasecurity/add-folder-scanning
add support for scanning folders
- Loading branch information
Showing
6 changed files
with
113 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Basic cfsec", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}/cmd/cfsec/main.go", | ||
"args": ["${workspaceFolder}/example/bucket.yaml"] | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/aquasecurity/cfsec/internal/app/cfsec/formatters" | ||
"github.com/aquasecurity/cfsec/internal/app/cfsec/parser" | ||
"github.com/aquasecurity/cfsec/internal/app/cfsec/resource" | ||
_ "github.com/aquasecurity/cfsec/internal/app/cfsec/rules" | ||
"github.com/aquasecurity/cfsec/internal/app/cfsec/scanner" | ||
) | ||
|
||
func main() { | ||
|
||
if len(os.Args) < 2 { | ||
os.Args = append(os.Args, ".") | ||
if wd, err := os.Getwd(); err != nil { | ||
os.Args = append(os.Args, wd) | ||
} | ||
} | ||
filepath := os.Args[1] | ||
|
||
resources, err := parser.New(filepath) | ||
var resources resource.Resources | ||
var err error | ||
|
||
if stat, err := os.Stat(filepath); err == nil { | ||
if stat.IsDir() { | ||
resources, err = parser.NewForDirectory(filepath) | ||
} else { | ||
resources, err = parser.New(filepath) | ||
} | ||
if err != nil { | ||
fmt.Println(err.Error()) | ||
return | ||
} | ||
} else { | ||
panic(fmt.Errorf("couldn't find the filepath when stating")) | ||
} | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
s := scanner.New() | ||
results := s.Scan(resources) | ||
|
||
formatters.FormatDefault(os.Stdout, results, "") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"Parameters": { | ||
"BucketName": { | ||
"Type": "String", | ||
"Default": "naughty" | ||
}, | ||
"BucketKeyEnabled": { | ||
"Type": "Boolean", | ||
"Default": false | ||
} | ||
}, | ||
"Resources": { | ||
"S3Bucket": { | ||
"Type": "AWS::S3::Bucket", | ||
"Properties": { | ||
"BucketName": { | ||
"Ref": "BucketName" | ||
}, | ||
"BucketEncryption": { | ||
"ServerSideEncryptionConfiguration": [ | ||
{ | ||
"BucketKeyEnabled": { | ||
"Ref": "BucketKeyEnabled" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters