-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup, simplification, and preparation for new modules (#14)
* Large code cleanup in preparation for expanding with new modules * Fixed typo in github action Co-authored-by: Britton Hayes <[email protected]>
- Loading branch information
1 parent
68cfa8d
commit 753aa43
Showing
36 changed files
with
807 additions
and
994 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/brittonhayes/pillager/hunter" | ||
"github.com/brittonhayes/pillager/rules" | ||
"github.com/spf13/afero" | ||
) | ||
|
||
func main() { | ||
// Create a new hunter config | ||
c := hunter.NewConfig(afero.NewOsFs(), ".", true, rules.Load(""), hunter.StringToFormat("JSON")) | ||
|
||
// Create a new hunter from the config | ||
h := hunter.NewHunter(c) | ||
|
||
// Start hunting | ||
_ = h.Hunt() | ||
} |
File renamed without changes.
File renamed without changes.
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 @@ | ||
[email protected] |
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 |
---|---|---|
|
@@ -13,3 +13,4 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
[email protected] | ||
[email protected] |
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,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEAsZsEGWDwTgdodV5CXE6it5k7ttD2SN+VTOLY+KLD0pISpZwq | ||
GQW5u8cfz4yLDm2CWb5wPXhC49Xh5WXB0xjnIbrjU+vIJB46SFyZf73yF8cMtx62 | ||
LnCE28YrqOgQB0QLrPL3fP9JfaZRKzTbE/Ydu11eJSvTpWeyRoLiQpudiQtetSJk | ||
52q6wpCIYSw+eLV8PiycqBMXreL4+qghbwSf06Ulq/k3I780Fksa4YoPAdSJBsyd | ||
T1dBPpVueWXiZDDNUDlIEtyMXVZwxM7M0NhyiQ8eq7rkd7Gy2ZqjdhMQyEwCSyRU | ||
I2kJL4HsVECbNtriUH6wGOTVHlTc5m+0LXI1YwIDAQABAoIBAEpSZV+9ajIs9XCQ | ||
FlMMcRlFnXB+d2G9dnvrPgKmEi4vBHCbLh60f6ntxQkUdih+eRrXD58ZkVxIZ7SY | ||
ZYjSFf7Od0zqESHUKG2Zmn6TXRjIKjEDQBek7GQPxLt1CSgROJWSQzDin71d+P+M | ||
qdTrnDuI8dm6QmIoR7ksEkTvW/g5wFA+qJFHPYtYxN/zasL3JRuMi+SwNgiQBW9v | ||
lhFdrgJICsBiCKAKhYmo2dNQKVDiiHW9kqyBmyGd5HKPFa8eN7vJfaOkB4tWy66G | ||
0hyFG1YLDKO6MCZa3VxedjUyD1YE0KMy4zpXR1OdgxdOgFlWIpvvgD03TmU3wTdE | ||
UHiJI/ECgYEA2lMaSMSsq8Ye1DWpr4w/UEaRBAqoBRUKrm6Bn8jScuC/E1b2bZ/g | ||
TXCscqKScDOHfNhTTrkenb274A5hiXCtz/8OkABC1b03+WnJNRyoIDj6kWQwOU2j | ||
ls8lYQKTsbKLpkOxJuANKQNpkIO3dcnHTwcNxvywBGqxAxL5DsykvJsCgYEA0EES | ||
V6J8zWfJ3dUppj9E7msF/LnLV6pdhfLBbWAApv00HhIrDmwMLW3cYc5RbBJ4+2oE | ||
xUZcj7ipLyBymHYrE//91aSuDTf4Y/IuS2szK3+UiBBDmxgt59lltlCVdhptNeW4 | ||
Iu/dr1zlzjOsJQa1k7JqludInhD0xJ4jussBYtkCgYAaOxXTXF3qnXkiwffLMayB | ||
tpjBxY3+XlLUNk64peYzCzGp3y7oaOcIJttxQnsZo/dJVqxbrv4wsZUbDF9HphQc | ||
A2b6gi2FhKBvBPi5uuGwTWg9g64PlHZtLiItj6OzG+KPbV6hbxXlsZVDWa/3JPEf | ||
W5eaKs3zGeZ+mg72ajv4tQKBgDMB/TAhyFe3OCZxc4YYsRWEeS7xgvCx9b49O0tC | ||
3GYKVp2W7ZzWshTed8As/Jxv2doamZiIJ1u8axPz6p2VM+/uH4oYj9kFAH3ab6Rh | ||
WWMqGINLGIQAZB4JjXQeQL1ws5cj8Pn9rlqpclATL/LRtd+7L4hOlebBWHJgGXhD | ||
CM/hAoGBAJC3PdClk2nUT3gVLSaIaS+MuwV/pOIydB8mP7arTW/I1hR/m32pNdhL | ||
o7FreZIOKDPWPcjd4hKlyMtteQoZtBT8mzvOKMnKGT4D3m+tHqQddxabBQ3yeDmh | ||
wXfDn7PCx2tH98tQoo9wO+HuRdgXTLjlrJ7tSV8ovLQmXUynOw9D | ||
-----END RSA PRIVATE KEY----- |
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,71 +1,42 @@ | ||
package main_test | ||
|
||
import ( | ||
"github.com/brittonhayes/pillager/pkg/hunter" | ||
"github.com/spf13/afero" | ||
"log" | ||
"os" | ||
"testing" | ||
|
||
"github.com/brittonhayes/pillager/hunter" | ||
"github.com/brittonhayes/pillager/rules" | ||
"github.com/spf13/afero" | ||
"github.com/zricethezav/gitleaks/v7/scan" | ||
) | ||
|
||
// A benchmark of the Hunter Load Rules method | ||
func BenchmarkHunterLoadRules(b *testing.B) { | ||
for n := 0; n < b.N; n++ { | ||
hunter.LoadRules("") | ||
rules.Load("") | ||
} | ||
} | ||
|
||
// A benchmark of the Hound Fetch method which | ||
// A benchmark of the Hound Howl method which | ||
// prints results out in desired format | ||
func BenchmarkHunterHoundFetch(b *testing.B) { | ||
func BenchmarkHunterHoundHowl(b *testing.B) { | ||
b.StopTimer() | ||
h := hunter.NewHound(&hunter.Config{ | ||
System: afero.NewMemMapFs(), | ||
Rules: hunter.LoadRules(""), | ||
Rules: rules.Load(""), | ||
Format: hunter.JSONFormat, | ||
}) | ||
h.Findings = []hunter.Finding{ | ||
{ | ||
Count: 1, | ||
Message: "Found something juicy", | ||
Path: "example.toml", | ||
Loot: []string{"Token 1234560"}, | ||
findings := scan.Report{ | ||
Leaks: []scan.Leak{ | ||
{Line: "[email protected]", LineNumber: 16, Offender: "[email protected]", Rule: "Email Addresses"}, | ||
}, | ||
} | ||
|
||
b.StartTimer() | ||
for n := 0; n < b.N; n++ { | ||
defer quiet()() | ||
h.Fetch() | ||
} | ||
} | ||
|
||
// A benchmark of the Hunter Inspect method | ||
func BenchmarkHunterInspect(b *testing.B) { | ||
b.StopTimer() | ||
fs := afero.NewMemMapFs() | ||
f, err := fs.Create("fake.toml") | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer f.Close() | ||
_, err = f.Write([]byte(`[email protected]`)) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
h := hunter.NewHunter(&hunter.Config{ | ||
System: fs, | ||
Rules: hunter.LoadRules(""), | ||
BasePath: ".", | ||
Verbose: true, | ||
Format: hunter.JSONFormat, | ||
}) | ||
|
||
b.StartTimer() | ||
for n := 0; n < b.N; n++ { | ||
defer quiet()() | ||
h.Inspect(f.Name(), h.Config.System) | ||
h.Howl(findings) | ||
} | ||
} | ||
|
||
|
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
Oops, something went wrong.