-
Notifications
You must be signed in to change notification settings - Fork 91
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 #6 from UKHomeOffice/feature/cli
cli: Adds scanrepo CMD
- Loading branch information
Showing
9 changed files
with
84 additions
and
8 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
release | ||
/repo-security-scanner | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
# repo-security-scanner | ||
|
||
|
||
## Installation | ||
|
||
```make install``` | ||
1. [Download](../../releases) the latest stable release of the CLI tool for your architecture | ||
2. Extract the tar and move the ```scanrepo``` binary to somewhere in your `$PATH`, eg `/usr/bin` | ||
|
||
----------------------------------------------------------- | ||
|
||
## Example Usage | ||
|
||
Check the entire history of the current branch for secrets. | ||
|
||
``` | ||
$ git log -p | scanrepo | ||
``` |
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,63 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/techjacker/diffence" | ||
) | ||
|
||
func main() { | ||
|
||
rPath := flag.String("rules", "", "path to custom rules in JSON format") | ||
flag.Parse() | ||
|
||
info, _ := os.Stdin.Stat() | ||
if (info.Mode() & os.ModeCharDevice) == os.ModeCharDevice { | ||
log.Fatalln("The command is intended to work with pipes.") | ||
return | ||
} | ||
|
||
var ( | ||
err error | ||
rules *[]diffence.Rule | ||
) | ||
|
||
if len(*rPath) > 0 { | ||
rules, err = diffence.LoadRulesJSON(*rPath) | ||
} else { | ||
rules, err = diffence.LoadDefaultRules() | ||
} | ||
if err != nil { | ||
log.Fatalf("Cannot load rules\n%s", err) | ||
return | ||
} | ||
|
||
diff := diffence.DiffChecker{Rules: rules} | ||
res, err := diff.Check(bufio.NewReader(os.Stdin)) | ||
if err != nil { | ||
log.Fatalf("Error reading diff\n%s\n", err) | ||
return | ||
} | ||
|
||
matches := res.Matches() | ||
if matches > 0 { | ||
i := 1 | ||
fmt.Printf("Diff contains %d offenses\n\n", matches) | ||
for filename, rule := range res.MatchedRules { | ||
fmt.Printf("------------------\n") | ||
fmt.Printf("Violation %d\n", i) | ||
fmt.Printf("File: %s\n", filename) | ||
fmt.Printf("Reason: %#v\n\n", rule[0].Caption) | ||
i++ | ||
} | ||
// finding violations constitutes an error | ||
os.Exit(1) | ||
return | ||
} | ||
fmt.Printf("Diff contains NO offenses\n\n") | ||
os.Exit(0) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# package | ||
github.com/UKHomeOffice/repo-security-scanner | ||
|
||
github.com/techjacker/diffence 6f41b9b0a8150e165cd297ae3e00129766cf8a9b | ||
github.com/techjacker/diffence 5aa50982d614156536dec11f93f178fdf43b3274 | ||
github.com/julienschmidt/httprouter 8a45e95fc75cb77048068a62daed98cc22fdac7c |
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 @@ | ||
RELEASE_VERSION=0.2.0 |