Skip to content

Commit f5f9afc

Browse files
authored
Merge pull request #11 from UKHomeOffice/feature/216-cli-commit-id
216-cli-commit-id: Adds commit hash to violation output logs
2 parents 39ba485 + af71395 commit f5f9afc

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ Check the entire history of the current branch for secrets.
1717

1818
```
1919
$ git log -p | scanrepo
20+
21+
------------------
22+
Violation 1
23+
Commit: 4cc087a1b4731d1017844cc86323df43068b0409
24+
File: web/src/db/seed.sql
25+
Reason: "SQL dump file"
26+
27+
------------------
28+
Violation 2
29+
Commit: 142e6019248c0d53a5240242ed1a75c0cc110a0b
30+
File: config/passwords.ini
31+
Reason: "Contains word: password"
32+
33+
...
2034
```
2135

2236
-----------------------------------------------------------

TODO.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
- [ ] type []Stats == logger = strings.Stringer() interface -> for creating string for email
2-
- [ ] Add email notifications (+ interface + tests)
3-
4-
5-
- [ ] Enable analysis of private github repos (authenticate using integration ID + private key - add to secrets)
6-
1+
### bufio.NewScanner Limitations
2+
```
3+
// Programs that need more control over error handling or large tokens,
4+
// or must run sequential scans on a reader, should use bufio.Reader instead.
5+
```
76

7+
### TODO
88
- [ ] Analyze body of commits (added/removed lines)
9-
10-
119
- [ ] Add concurrency (parallelize requests to github API)
1210
- [ ] Add context + timeout to requests to github API

cmd/scanrepo/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ func main() {
5454

5555
i := 1
5656
fmt.Fprintf(os.Stderr, "Diff contains %d offenses\n\n", matches)
57-
for filename, rule := range res.MatchedRules {
57+
for diffKey, rule := range res.MatchedRules {
5858
fmt.Fprintf(os.Stderr, "------------------\n")
5959
fmt.Fprintf(os.Stderr, "Violation %d\n", i)
60+
commit, filename := diffence.SplitDiffHashKey(diffKey)
61+
if commit != "" {
62+
fmt.Fprintf(os.Stderr, "Commit: %s\n", commit)
63+
}
6064
fmt.Fprintf(os.Stderr, "File: %s\n", filename)
6165
fmt.Fprintf(os.Stderr, "Reason: %#v\n\n", rule[0].Caption)
6266
i++

hello

Whitespace-only changes.

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
RELEASE_VERSION=0.3.1
1+
RELEASE_VERSION=0.4.0
22
RELEASE_BUILD_PATH=./cmd/scanrepo

0 commit comments

Comments
 (0)