dependabot / fetch-metadata

Extract information about the dependencies being updated by a Dependabot-generated PR.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option to skip verifying the `dependabot` user internally

jeffwidman opened this issue · comments

@yeikel pointed out that we don't need to do the internal check within the action if we recommend on the Readme that users check the user before executing the action:

I think this is the reason the check exists within the code... the concern is that users may not realize they need to set that, and so may fire off spurious requests... so it's defensive coding to protect the API from ignorant/careless users.

That said, I agree the volume of calls here is probably pretty low, so it may be fine to remove this... 🤷‍♂️

Removing it would simplify the code / config complexity since the DEPENDABOT_LOGIN const and associated logic of letting users customize the user simply disappears...

I'm going to run this by the team internally to see what folks think...

commented

I think that the only downside of implementing this is that we will need to release a new breaking version and inform the users about it.

Other than that, I assume that most users will copy/paste the examples

From @brrygrdn via slack:

As I recall, the intent of that method was to avoid anyone tacking on additional commits or force-pushing an edited commit that would trigger a user's automation. The reason we do the 'belt-and-braces' in the workflow is more about avoiding jobs running on every PR ending in errors rather than just skipping.

I think the intent that content should be verified as best possible is still worthwhile because people are using this as a gateway to automerging, etc, so as an official action I think we should avoid trusting the content by default.

Adding an option to disable content verification seems ok though as in that case the user knows what they are doing and has taken the safety catch off.

On the surface that makes sense to me, I hadn't even considered the case of someone tacking on additional commits to an existing Dependabot PR.

However, the funky part is that the logic is not checking the author of the last commit, it's checking the PR author:

// Don't bother hitting the API if the PR author isn't Dependabot
if (pr.user.login !== DEPENDABOT_LOGIN) {
core.debug(`PR author '${pr.user.login}' is not Dependabot.`)
return false

And on the flip side, only checking the PR author makes sense for the cases where someone has automation for an additional commit on every :dependabot: PR, such as using https://github.com/jonabc/licensed-ci.

So that kinda prevents us fully switching to checking the latest commit author rather than PR author.

That said, I'm still fine with leaving the existing check for defensive purposes, but does mean we could probably loosen the API over in #331 from specifying a custom user to simple on/off of enforcing the in-code check.

@brrygrdn feel free to add mroe comments if I'm misunderstanding or overlooking something.

For a data point, I've occasionally manually combined the changes from multiple Dependabot PRs in cases where it doesn't make sense for the individual package updates to be applied separately (e.g. @sentry/* where all package versions need to be kept aligned to result in a working system, but Dependabot today raises separate PRs for each directly-referenced dependency).
When I've done that, I've also gone and manually combined the metadata stanzas in the resulting commit message to indicate the now-combined update being applied. To me, that seems like a completely valid use case where I would want any tooling that reads this metadata to read the updated metadata even though my user had committed (and potentially authored) the commit. 🙂

Fixed by #336