Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
github-upload-action-secrets: input validation
Make sure --receiver refers to a valid org or repository.
  • Loading branch information
allisonkarlitskaya committed Jul 9, 2021
commit 6dd849493fd198df85079980456a6191ee26c6f9
7 changes: 7 additions & 0 deletions github-upload-action-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import argparse
import os
import re
import sys
import urllib.parse
from base64 import b64encode
Expand Down Expand Up @@ -65,6 +66,12 @@ def main():
parser.add_argument("secrets_dir", help="directory with one file per secret")
opts = parser.parse_args()

NAME_RE = r'[a-z][-0-9a-z_.]*'
REPO_RE = f'{NAME_RE}/{NAME_RE}'

if opts.receiver and not re.fullmatch(f'{NAME_RE}|{REPO_RE}', opts.receiver, re.I):
parser.error('--receiver specifies an invalid org or repository name')
Comment thread
allisonkarlitskaya marked this conversation as resolved.

if not opts.receiver:
if not opts.env:
# get organization of the current repo, if available
Expand Down