Skip to content

Update more SecurityAndAnalysis attributes#3025

Merged
EnricoMi merged 3 commits intoPyGithub:mainfrom
squatched:main
Aug 26, 2024
Merged

Update more SecurityAndAnalysis attributes#3025
EnricoMi merged 3 commits intoPyGithub:mainfrom
squatched:main

Conversation

@squatched
Copy link
Copy Markdown
Contributor

@squatched squatched commented Aug 21, 2024

Recently, /orgs/{org}/repos started returning something that doesn't match the schema given in the docs. This updates SecurityAndAnalysis to reflect what is actually being returned by this endpoint.

I am reaching out to GitHub to determine what's going on, if this is a permanent change, then I will push this.

Recently, '/orgs/{org}/repos' was updated to not match the schema given
in the docs
(https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-organization-repositories).
This updates SecurityAndAnalysis to reflect what is actually being
returned by this endpoint.
@squatched
Copy link
Copy Markdown
Contributor Author

Here's what's currently getting returned:

$ curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer [snip]" "https://api.github.com/orgs/[org_slug]/repos?per_page=1" | jq '.[0].security_and_analysis'
{
  "security_and_analysis": {
    "secret_scanning": {
      "status": "disabled"
    },
    "secret_scanning_push_protection": {
      "status": "disabled"
    },
    "dependabot_security_updates": {
      "status": "enabled"
    },
    "secret_scanning_non_provider_patterns": {
      "status": "disabled"
    },
    "secret_scanning_validity_checks": {
      "status": "disabled"
    }
  }
}

It turns out that these advanced security features are sometimes not
returned due to your licensing config (if you disable GHAS then the
'advanced_security' bit of a repository's 'security_and_analysis' is
just not included). There may be more features here as the documentation
doesn't include some of these but I have personally seen them (in this
case, that would just be 'secret_scanning_validity_checks' which appears
to be a limited rollout at the moment but might as well support it).
@squatched
Copy link
Copy Markdown
Contributor Author

Here's what's currently getting returned:

$ curl -s -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer [snip]" "https://api.github.com/orgs/[org_slug]/repos?per_page=1" | jq '.[0].security_and_analysis'
{
  "security_and_analysis": {
    "secret_scanning": {
      "status": "disabled"
    },
    "secret_scanning_push_protection": {
      "status": "disabled"
    },
    "dependabot_security_updates": {
      "status": "enabled"
    },
    "secret_scanning_non_provider_patterns": {
      "status": "disabled"
    },
    "secret_scanning_validity_checks": {
      "status": "disabled"
    }
  }
}

secret_scanning_validity_check is in limited rollout ATM so I would imagine it will get added to the response schema in due time.

Fix a bug in SecurityAndAnalysis repr function, but also reorder the
expected output of repr to match actual output order.
@squatched squatched marked this pull request as ready for review August 22, 2024 16:25
Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EnricoMi EnricoMi changed the title Update SecurityAndAnalysis For New Response Schema Update more SecurityAndAnalysis attributes Aug 26, 2024
@EnricoMi EnricoMi added this pull request to the merge queue Aug 26, 2024
Merged via the queue into PyGithub:main with commit fa16827 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants