Skip to content

Commit

Permalink
Exclude archived repos
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyb committed Nov 29, 2023
1 parent a92a942 commit c393fb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions metrics/github/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_vulnerabilities(org):
repositories(first: 100) {
nodes {
name
archivedAt
vulnerabilityAlerts(first: 100) {
nodes {
number
Expand Down Expand Up @@ -89,7 +90,8 @@ def parse_vulnerabilities(vulnerabilities, org):
for repo in vulnerabilities:
repo_name = repo["name"]
alerts = repo["vulnerabilityAlerts"]["nodes"]
if not alerts:

if repo["archivedAt"] or not alerts:
continue

earliest_date = datetime.fromisoformat(alerts[0]["createdAt"]).date()
Expand All @@ -106,8 +108,8 @@ def parse_vulnerabilities(vulnerabilities, org):

def print_vulnerabilities(vulns): # pragma: no cover
print(f"There are {len(vulns)} alerts")
print(parse_vulnerabilities(vulns))
print(parse_vulnerabilities(vulns, "opensafely-core"))


if __name__ == "__main__": # pragma: no cover
print_vulnerabilities(get_vulnerabilities())
print_vulnerabilities(get_vulnerabilities("opensafely-core"))
1 change: 1 addition & 0 deletions tests/metrics/github/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def fake_vulnerabilities(org):
github_response = [
{
"name": "opencodelists",
"archivedAt": None,
"vulnerabilityAlerts": {
"nodes": [
{
Expand Down

0 comments on commit c393fb0

Please sign in to comment.