Skip to content

Commit 16419e3

Browse files
final troubleshooting and debugging
1 parent a8bb42f commit 16419e3

File tree

6 files changed

+25
-14
lines changed

6 files changed

+25
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ Keep in mind that when you submit your pull request, you'll need to sign the CLA
239239
- [ ] Multi-threading
240240
- [ ] Better context detection and false positive filtering (GitHound, machine learning)
241241
- [ ] Use Rusoto instead of s3-rust
242-
- [ ] Add JIRA scanner
243-
- [ ] Add file-system & archive scanner
242+
- [x] Add JIRA scanner
243+
- [x] Add file-system & archive scanner
244244
- [ ] Use Rust features to reduce compilation dependencies?
245245

246246
- 1.2: Integration with larger scripts and UIs

scripts/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sudo systemctl daemon-reload
2525
sudo systemctl enable ghe_secret_monitor
2626
```
2727

28-
You can then perform a one-time execution of secret_scanner with the command
28+
You can then perform a one-time execution of secret_monitor with the command
2929
`sudo service ghe_secret_monitor start` and examine the results in /var/log/messages
3030

3131
## jira_secret_monitor.py
@@ -34,7 +34,7 @@ This is a Python script, also re-written based on Douglas Day's work, that perfo
3434
1) It scans all JIRA tickets modified in the last 24 hours for secrets using gottingen_hog.
3535
2) Within those JIRA tickets it looks for GDrive links and scans those docs for secrets using anakmali_hog.
3636
It then collects the results and outputs them to New Relic Insights. You can use
37-
the same installation method as above, substituting jira_secret_scanner for secret_scanner
37+
the same installation method as above, substituting jira_secret_monitor for secret_monitor
3838
in each step.
3939

4040
## gh_org_scanner.py
@@ -53,7 +53,7 @@ blacklist of words. It outputs the results as output_filtered.csv
5353

5454
This is a simple script meant to retrieve the latest pypi package (provided through environment variables) and perform a
5555
Rusty Hog scan on the contents of the download. It will then post the results to Insights. You can use
56-
the same installation method as above, substituting pypi_secret_monitor for secret_scanner
56+
the same installation method as above, substituting pypi_secret_monitor for secret_monitor
5757
in each step.
5858

5959
You will need to supply 4 environment variables to it:
@@ -66,7 +66,7 @@ DUROC_HOG_PATH - the path to the duroc hog binary (relative or absolute)
6666

6767
Based on pypi_secret_monitor, this is a simple script meant to retrieve the latest rubygem package (provided through
6868
environment variables) and perform a Rusty Hog scan on the contents of the download. It will then post the results to
69-
Insights. You can use the same installation method as above, substituting rubygem_secret_monitor for secret_scanner
69+
Insights. You can use the same installation method as above, substituting rubygem_secret_monitor for secret_monitor
7070
in each step.
7171

7272
You will need to supply 4 environment variables to it:

scripts/ghe_secret_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# sudo systemctl enable ghe_secret_monitor
1818
# ```
1919
#
20-
# You can then perform a one-time execution of secret_scanner with the command
20+
# You can then perform a one-time execution of secret_monitor with the command
2121
# `sudo service ghe_secret_monitor start` and examine the results in /var/log/messages
2222

2323
from datetime import datetime, timedelta

scripts/jira_secret_monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
# hit the JIRA API to retrieve the comments for each issue
7474
url = f"{JIRA_URL}rest/api/2/issue/{issue['key']}/comment"
7575
r = requests.get(url, auth=(JIRA_USERNAME, JIRA_PASSWORD))
76-
comments = r.json()['comments']
76+
comments = r.json().get('comments', [])
7777
for comment in comments:
7878
# find any google doc links in the comment and add them to our list (links)
7979
matches = gdoc_re.findall(comment['body'])

scripts/jira_secret_monitor.timer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Unit]
2-
Description=Run secret_scanner every day at 11:30pm pacific
2+
Description=Run secret_monitor every day at 11:30pm pacific
33
Requires=jira_secret_monitor.service
44

55
[Timer]

src/bin/gottingen_hog.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,22 @@ fn run(arg_matches: &ArgMatches) -> Result<(), SimpleError> {
145145

146146
let json_results = get_issue_json(client, auth_headers, &full_url);
147147

148-
let description = json_results
149-
.get("fields").unwrap()
150-
.get("description").unwrap()
151-
.as_str().unwrap()
152-
.as_bytes();
148+
let fields = json_results.get("fields").unwrap();
149+
150+
let description = match fields.get("description") {
151+
Some(d) => match d.as_str() {
152+
Some(e) => e.as_bytes(),
153+
None => {
154+
info!("The JIRA ticket description was set to null!");
155+
"".as_bytes()
156+
}
157+
}
158+
None => {
159+
info!("The JIRA ticket description was not present!");
160+
"".as_bytes()
161+
}
162+
};
163+
153164

154165
// find secrets in issue body
155166
let mut secrets = get_findings(&secret_scanner, base_url, issue_id, description, String::from("Issue Description"));

0 commit comments

Comments
 (0)