Skip to content

Commit 0ca0d2b

Browse files
authored
Merge pull request #42 from ONS-Innovation/secret_scanning_repo_url
KEH-1060 | Add Repository URL to Secret Scanning Data
2 parents 21e6b8c + d00d7be commit 0ca0d2b

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

data_logger/src/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,9 @@ def get_secret_scanning_data(logger: wrapped_logging, rest: github_api_toolkit.g
899899

900900
formatted_alert = {
901901
"repository": alert["repository"]["name"],
902+
"repository_url": alert["repository"]["html_url"],
902903
"creation_date": alert["created_at"],
903-
"url": alert["html_url"]
904+
"alert_url": alert["html_url"],
904905
}
905906

906907
secret_scanning_data.append(formatted_alert)

docs/data_logger/secret_scanning.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ This dataset includes all open alerts within the threshold, regardless of whethe
1212
[
1313
{
1414
"repository": "{repo}",
15+
"repository_url": "https://github.com/{org}/{repo}",
1516
"creation_date": "2024-12-11T23:54:00Z",
16-
"url": "https://github.com/{org}/{repo}/security/secret-scanning/{alert_id}"
17+
"alert_url": "https://github.com/{org}/{repo}/security/secret-scanning/{alert_id}"
1718
},
1819
]
1920
```

src/secret_scanning/collection.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ def load_secret_scanning(_s3, bucket: str) -> pd.DataFrame | None:
3232
# Rename the columns to be more readable
3333
df_secret_scanning.columns = [
3434
"Repository",
35+
"Repository URL",
3536
"Creation Date",
3637
"URL",
3738
]
3839

40+
# Remove repository URL since it isn't used (Database requirement only)
41+
df_secret_scanning = df_secret_scanning.drop(columns=["Repository URL"])
42+
3943
# Add Alert Age (Days) to the DataFrame
4044
df_secret_scanning["Alert Age (Days)"] = datetime.now() - pd.to_datetime(df_secret_scanning["Creation Date"]).dt.tz_localize(None)
4145
df_secret_scanning["Alert Age (Days)"] = df_secret_scanning["Alert Age (Days)"].dt.days

0 commit comments

Comments
 (0)