create-pull-request icon indicating copy to clipboard operation
create-pull-request copied to clipboard

Github secrets checked into code

Open scottmelhop opened this issue 5 years ago • 2 comments

When using this action on a repo with secrets, my secret is added as a file, committed to the branch and is visible in the PR

Steps to reproduce.

  1. Add secret to repo
  2. Use action in workflow
  3. Run action
  4. View pr

image

scottmelhop avatar Aug 17 '21 17:08 scottmelhop

Hi @scottmelhop

There are two main solutions to avoid including modified or new files in a PR.

  1. Add the paths of artifacts you don't want to be committed to .gitignore. This is very simple and should be a good way to solve the problem if you can determine the path beforehand. For example, if temporary files (that you don't want to be committed) are being created in a workflow, create them in a directory called temp and include that directory in your .gitignore.

  2. Make your own commits as described here containing just the paths that you want. After you have made the commits execute the following commands to remove all other changes. The first command stages all other changes, then git resets to delete them. (You need to stage them first otherwise git reset won't delete untracked files).

    git add -A
    git reset --hard HEAD
    

peter-evans avatar Aug 18 '21 01:08 peter-evans

Yes there are ways around it, and I think this is actually a bigger flaw with Github actions. I can

  • Create an action to show all the secrets in my repo
  • Create a PR against a protected branch that I can then approve as the reviewer, effectively disabling that level of branch protection

For our organisation this will likely be a security risk and we will have github actions disabled. :(

scottmelhop avatar Aug 18 '21 08:08 scottmelhop