NASA-PDS / software-issues-repo

Issue tracking repository as a centralized entry point for general PDS software bugs and feature requests.
Apache License 2.0
0 stars 0 forks source link

Refactor templates repo for detect secrets and distribute to all EN repos #55

Closed jordanpadams closed 6 months ago

jordanpadams commented 1 year ago

đź’ˇ Description

https://nasa-ammos.github.io/slim/continuous-integration/starter-kits/#git-secrets

Probably need discussion with secrets/credentials provider: https://github.com/awslabs/git-secrets#id20

Should follow the guidelines and recommendations from here: https://github.com/NASA-AMMOS/slim/issues/89

nutjob4life commented 8 months ago

Hi @jordanpadams, in between the time this issue was created (Jan 17) and the time it was put onto the backlog (Oct 17), a major thing has changed over at SLIM, that being: they no longer recommend git-secrets.

Instead, they've settled onto another tool, detect-secrets, which they've documented extensively. It looks like detect-secrets can do a whole lot more than git-secrets, which worked fine for AWS keys. Yet detect-secrets can also find absolute file paths (which you commented on), sensitive email addresses, hostnames—and even do entropy analysis (automatic detection of secrets based on their high degree of randomness).

We've already settled onto git-secrets for the template-repo-python and template-repo-java, and I can certainly spread git-secrets out to the rest of our repositories.

But, as the issue description says above ↑, do we want to follow the guidelines at NASA-AMMOS/slim#89—which would mean going to detect-secrets—or do what the issue title says—which would be propagating git-secrets?

jordanpadams commented 8 months ago

@nutjob4life feel free to refactor all this towards the best solution you deem for our projects. in this case, let's role with detect-secrets.

nutjob4life commented 8 months ago

To resolve this, I need to use the sandbox, however I have a prerequisite pull request that'll need to be merged so I can get the sandbox working again.

nutjob4life commented 8 months ago

Notes to self.

Gathering the Tools

All developers—whether they use Python or Java—will need Python. (Honestly, I'm not sure how I feel about this.)

One quickie idea:

$ cd $HOME
$ python3 -m venv bin
$ cat > bin/requirements.txt <<EOF
pre-commit ~= 3.5.0
detect-secrets @ git+https://github.com/NASA-AMMOS/slim-detect-secrets.git@exp
EOF
$ bin/pip3 install --requirement bin/requirements.txt

Establishing the Baseline

To generate the baseline of PDS repositories, we'll need to exclude far more than the SLIM folk think, as we don't commit generated files (I hope they aren't either).

For Python

detect-secrets scan . \
    --all-files \
    --disable-plugin AbsolutePathDetectorExperimental \
    --exclude-files '\.secrets..*' \
    --exclude-files '\.git.*' \
    --exclude-files '\.mypy_cache' \
    --exclude-files '\.pytest_cache' \
    --exclude-files '\.tox' \
    --exclude-files '\.venv' \
    --exclude-files 'venv' \
    --exclude-files 'dist' \
    --exclude-files 'build' \
    --exclude-files '.*\.egg-info' > .secrets.baseline

For Maven

detect-secrets scan . \
    --all-files \
    --disable-plugin AbsolutePathDetectorExperimental \
    --exclude-files '\.secrets..*' \
    --exclude-files '\.git.*' \
    --exclude-files 'target' > .secrets.baseline
nutjob4life commented 7 months ago

Progress: this is now functioning in the sandbox's pds-template-repo-python. Next step is to try it in the sandbox pds-template-repo-java and then see if we want to roll it out everywhere, and update our various instructions.

(Still have an open question about whether we want to force Java developers to install Python.)

nutjob4life commented 7 months ago

Progress: this is now functioning in the sandbox's pds-template-repo-java.

I've also updated the READMEs for both Java and Python with instructions on how to use detect-secrets. These instructions reference a wiki page that is yet to be written, so these are the next steps:

  1. Write the wiki page so the links from the READMEs aren't 404
  2. Create PRs for these changes from the sandbox → the real NASA-PDS organization
  3. Once approved, roll out all these changes to the rest of the NASA-PDS repositories
nutjob4life commented 7 months ago

Suggested repositories:

tloubrieu-jpl commented 7 months ago

@nutjob4life is investigating 4 repos which do not behave as expected. The others are good.

nutjob4life commented 7 months ago

It turns out it was three repositories, not four, that had problems with server-side secrets-detection via GitHub Actions.

Only one of those repositories got merged into main, so I've filed a fresh pull request to fix the problem with the server-side secrets detection.

The other two repositories, doi-ui and registry, had their pull requests remain open. So I've pushed additional commits to those branches to address the problems with server-side secrets detection.

The doi-ui PR has already been merged, leaving (at the time of this writing), the PR for secrets on registry open.

In addition, these PRs for secrets detection remain open at the time of this writing—but had no issues with their secrets-detection status checks in GitHub Actions:

jordanpadams commented 6 months ago

@nutjob4life one more I found: https://github.com/NASA-PDS/wds-react-legacy/tree/main/.github/workflows

nutjob4life commented 6 months ago

@jordanpadams pull request created

jordanpadams commented 6 months ago

Closing this out since most repos have been retrofitted. Will add to additional repos as needed if any were missed.