Skip to content

Automatically credit remediation developers and reviewers - #61

Open
sethmlarson wants to merge 3 commits into
python:mainfrom
sethmlarson:auto-credit-reviewers
Open

Automatically credit remediation developers and reviewers#61
sethmlarson wants to merge 3 commits into
python:mainfrom
sethmlarson:auto-credit-reviewers

Conversation

@sethmlarson

Copy link
Copy Markdown
Collaborator

The bot can automatically credit people who participate in creating a patch or reviewing the patch privately. Does not override credits that already exist for an individual.

Comment thread src/psrt_ghsa_bot/app.py Outdated
Comment thread src/psrt_ghsa_bot/app.py Outdated
Comment thread src/psrt_ghsa_bot/app.py Outdated
Comment thread src/psrt_ghsa_bot/app.py Outdated
Comment thread src/psrt_ghsa_bot/app.py
Comment thread src/psrt_ghsa_bot/app.py

# Find new credits for the security advisory.
if credits := get_security_advisory_credits(github, security_advisory):
patch_data["credits"] = credits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about existing credits?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I believe this is now handled in 27dd5d5 ? Although I believe the GitHub API already doesn't "clobber" in the PATCH method?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, can we check that we aren't just patching the same credits?

Comment thread tests/test_app.py
"cve_id": cve_id,
"collaborating_teams": [{"slug": team} for team in collaborating_teams],
"collaborating_users": [{"login": "octocat", "id": 1, "type": "User"}],
"private_fork": {"name": "repo-ghsa-xxxx-xxxx-xxxx", "owner": {"login": "owner"}},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Won't we loose coverage?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I removed this field to avoid needing to mock out the pull requests response for each test case that didn't process private_fork. All the test cases that use private_fork already set the value.

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you also please update the flow chart in the README for this, TiA!

Comment thread src/psrt_ghsa_bot/app.py

# Find new credits for the security advisory.
if credits := get_security_advisory_credits(github, security_advisory):
patch_data["credits"] = credits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, can we check that we aren't just patching the same credits?

Comment thread src/psrt_ghsa_bot/app.py
private_fork_repo = private_fork["name"]

try:
pull_requests = json.loads(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we please add a little comment re. the lack of pagination, just in case it somehow surprises someone down the line.

Comment thread src/psrt_ghsa_bot/app.py
)
except RequestFailed:
capture_exception()
raise RuntimeError("Request to list pull requests failed") from None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't have coverage for these cases (to ensure we don't leak any other output), but that can be a follow up.

Comment thread src/psrt_ghsa_bot/app.py
raise RuntimeError("Request to list pull requests failed") from None

for pull_request in pull_requests:
# fmt: off

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we really need these?

Comment thread src/psrt_ghsa_bot/app.py
)
except RequestFailed:
capture_exception()
raise RuntimeError("Request to list pull requests reviews failed") from None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could continue processing the next advisory instead?

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