Skip to content

Commit 1457cf5

Browse files
committed
cascading-run (push): validate event's sender
While a `push` that we already verified came from the `main` branch kind of implies that the person pushing that branch has write permissions, let's just add the usual permission check, too. Security is a game of layers. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 5c35d7d commit 1457cf5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

GitForWindowsHelper/cascading-runs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,16 @@ const handlePush = async (context, req) => {
271271
const pushRepo = req.body.repository.name
272272
const ref = req.body.ref
273273
const commit = req.body.after
274+
const sender = req.body.sender.login
274275

275276
if (pushOwner !== 'git-for-windows' || pushRepo !== 'git') {
276277
throw new Error(`Refusing to handle push to ${pushOwner}/${pushRepo}`)
277278
}
278279

279280
if (ref !== 'refs/heads/main') return `Ignoring push to ${ref}`
280281

282+
if (!await isAllowed(sender)) throw new Error(`${sender} is not allowed to do that`)
283+
281284
// See whether there was are already a `tag-git` check-run for this commit
282285
const { listCheckRunsForCommit, queueCheckRun, updateCheckRun } = require('./check-runs')
283286
const gitToken = await getToken(context, pushOwner, pushRepo)

0 commit comments

Comments
 (0)