pluribusdemoteam / codespace-java

0 stars 0 forks source link

Create method to verify Packages are coming from Secure Repositories #2

Open camclay opened 3 years ago

camclay commented 3 years ago

Problem statement: we don’t want teams/apps pulling libraries from the default sources on the public internet (npm.org, maven.org, etc.); we want them to go through our own package repo (artifactory).

JeffreyMFarley commented 3 years ago
#!/bin/bash

DIR="${1:-.}"

FAILS=0

EXT_RUBY="https://rubygems.org/"
EXT_NODE="https://registry.npmjs.org/"

## Ruby Check
while read -r file
do
    if grep -q "$EXT_RUBY" "$file"; then
      echo "$EXT_RUBY in $file";
      FAILS=1;
    fi
done < <(find $DIR -name "Gemfile.lock")

## npm Check
while read -r file
do
    if grep -q "$EXT_NODE" "$file"; then
      echo "$EXT_NODE in $file";
      FAILS=1;
    fi
done < <(find $DIR -name "package-lock.json")

if [ $FAILS -eq 1 ]; then
  echo -e "\nThis repo has files that are not in compliance";
  exit 1;
else
  echo "This repo is in compliance"
fi
$ ./artifactory_compliance.sh ./hoop
This repo is in compliance

$ ./artifactory_compliance.sh ./uscis-didit
https://rubygems.org/ in ./uscis-didit/services/ruby-api/Gemfile.lock
https://registry.npmjs.org/ in ./uscis-didit/services/ui/package-lock.json

This repo has files that are not in compliance
JeffreyMFarley commented 3 years ago

h/t to @camclay

How to turn shell script into an action

analavade commented 3 years ago

Using A Single Repository (Maven) https://maven.apache.org/guides/mini/guide-mirror-settings.html#using-a-single-repository Github Action to create maven settings https://github.com/whelk-io/maven-settings-xml-action