Skip to content

Add support for new RepositoryAdvisories API 🎉#2483

Merged
JLLeitschuh merged 2 commits intoPyGithub:masterfrom
JLLeitschuh:feat/JLL/support_repository_advisiories
Jun 9, 2023
Merged

Add support for new RepositoryAdvisories API 🎉#2483
JLLeitschuh merged 2 commits intoPyGithub:masterfrom
JLLeitschuh:feat/JLL/support_repository_advisiories

Conversation

@JLLeitschuh
Copy link
Collaborator

@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/support_repository_advisiories branch from 9cd7af4 to 5e1afde Compare March 31, 2023 14:58
@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/support_repository_advisiories branch from 5e1afde to e7a5d60 Compare April 4, 2023 16:37
@JLLeitschuh JLLeitschuh marked this pull request as ready for review April 4, 2023 16:38
@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2023

Codecov Report

Patch coverage: 95.11% and project coverage change: -0.13 ⚠️

Comparison is base (84912a6) 98.57% compared to head (1168ac3) 98.45%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2483      +/-   ##
==========================================
- Coverage   98.57%   98.45%   -0.13%     
==========================================
  Files         118      124       +6     
  Lines       11981    12407     +426     
==========================================
+ Hits        11810    12215     +405     
- Misses        171      192      +21     
Impacted Files Coverage Δ
github/Repository.py 97.10% <93.02%> (-0.11%) ⬇️
github/RepositoryAdvisoryCredit.py 93.61% <93.61%> (ø)
github/RepositoryAdvisory.py 93.83% <93.83%> (ø)
github/RepositoryAdvisoryCreditDetailed.py 95.65% <95.65%> (ø)
github/RepositoryAdvisoryVulnerability.py 98.57% <98.57%> (ø)
github/CWE.py 100.00% <100.00%> (ø)
github/GithubObject.py 98.84% <100.00%> (+0.02%) ⬆️
github/RepositoryAdvisoryVulnerabilityPackage.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Comment on lines +1461 to +1524
vulnerabilities: typing.Optional[
typing.Iterable[
github.RepositoryAdvisoryVulnerability.AdvisoryVulnerability
]
] = None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to the GitHub team I'm chatting with, this should not be optional. At least one must be supplied.

That GitHub's API currently supports passing an empty list, is a bug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Turns out this isn't a bug. It's implemented as-designed

@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/support_repository_advisiories branch 2 times, most recently from 48924fb to f4e1dc8 Compare April 4, 2023 17:35
@JLLeitschuh
Copy link
Collaborator Author

CI passes. Linting passses. AFAIK, everything has solid unit test coverage.

Seeking code reviews!

Copy link

@rthorpeii rthorpeii left a comment

Choose a reason for hiding this comment

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

The structure of the API objects and calls looks good to me!

@JLLeitschuh JLLeitschuh requested a review from rthorpeii April 5, 2023 22:14
@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/support_repository_advisiories branch from 31820e2 to 884f1c4 Compare April 19, 2023 21:48
Copy link
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, minor comments

self._requester, headers, data, completed=True
)

def create_repository_advisory(
Copy link
Collaborator

Choose a reason for hiding this comment

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

since this is on Repository, this could read:

Suggested change
def create_repository_advisory(
def create_advisory(

Or are there other methods that imply this naming convention?

private_vulnerability_reporting=False,
)

def report_security_vulnerability(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should read:

Suggested change
def report_security_vulnerability(
def report_security_advisory(

or

Suggested change
def report_security_vulnerability(
def create_security_advisory(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This API is used by reporters, not by maintainers, to report vulnerabilities.

I was trying to figure out a way to differentiate the create which is something only a repository admin can take, from the report which is an action any GitHub user can take.

Copy link
Collaborator

Choose a reason for hiding this comment

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

right, the link to the docs confused me, I think it is linking to creating an advisory, where it should link to creating a vulnerability

),
}

def get_repository_advisories(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here, repository could also be removed, but on the other hand, it returns a `RepositoryAdvisory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So does the one above. Which naming convention would you like to see used here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unless you have a strong preference, I think we should opt to use the naming convention in the GitHub API docs here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

agreed, keep it

] = None,
) -> github.RepositoryAdvisory.RepositoryAdvisory:
"""
:calls: `POST /repos/{owner}/{repo}/security-advisories/reports <https://docs.github.com/en/rest/security-advisories/repository-advisories#create-a-repository-security-advisory>`_
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the link should point to

https://docs.github.com/en/rest/security-advisories/repository-advisories#privately-report-a-security-vulnerability

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

private_vulnerability_reporting=False,
)

def report_security_vulnerability(
Copy link
Collaborator

Choose a reason for hiding this comment

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

right, the link to the docs confused me, I think it is linking to creating an advisory, where it should link to creating a vulnerability

@EnricoMi
Copy link
Collaborator

EnricoMi commented Jun 1, 2023

@JLLeitschuh happy to approve, please rebase and correct the doc links

@JLLeitschuh
Copy link
Collaborator Author

Will do, just been bogged down in other work

@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/support_repository_advisiories branch from 884f1c4 to 94d10ac Compare June 7, 2023 14:45
@JLLeitschuh JLLeitschuh force-pushed the feat/JLL/support_repository_advisiories branch from 94d10ac to c34ead0 Compare June 7, 2023 15:24
Copy link
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!

@JLLeitschuh JLLeitschuh merged commit daf62bd into PyGithub:master Jun 9, 2023
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.

4 participants