Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add base directory and pnpm support #1

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ ENV NODE_DOWNLOAD_URL https://nodejs.org/dist/v${NODE_VERSION}/${NODE_TARBALL_FI
ENV NODE_DOWNLOAD_SHA256 bf30432175ea8a95fa3e5fe09e96d9fc17b07099742d5c83c4cf9d0edfc411ff
ENV NPM_VERSION 6.14.8
ENV YARN_VERSION 1.22.0
ENV PNPM_VERSION 6.14.7
ENV NPM_CONFIG_LOGLEVEL info

COPY build/package.json build/yarn.lock /home/
Expand All @@ -140,11 +141,11 @@ RUN curl -fsSL "$NODE_DOWNLOAD_URL" -o node.tar.gz \
&& tar -C /usr/local -xzf node.tar.gz --strip-components=1 \
&& npm install -g npm@${NPM_VERSION} \
&& npm install -g yarn@${YARN_VERSION} \
&& npm install -g pnpm@${PNPM_VERSION} \
&& cd /home \
&& yarn install \
&& rm -rf /node.tar.gz package.json yarn.lock /tmp/* ~/.npm


### All other tools
ENV PIP_VERSION 18.1
COPY --from=builder /root/go/bin/sift /usr/local/bin
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ custom_info:
reports:
- uri: $INPUT_REPORT_URI
format: $INPUT_REPORT_FORMAT
verbose: $INPUT_REPORT_VERBOSITY" | tee $GITHUB_WORKSPACE/../salus-configuration.yaml
verbose: $INPUT_REPORT_VERBOSITY" | tee $GITHUB_WORKSPACE/../salus-configuration.yaml

cd /home && BUNDLE_GEMFILE=/home/Gemfile bundle exec /home/bin/salus scan --repo_path "$GITHUB_WORKSPACE" --config "$SALUS_CONFIGURATION"
cd /home && BUNDLE_GEMFILE=/home/Gemfile bundle exec /home/bin/salus scan --repo_path "$GITHUB_WORKSPACE/$BASE_DIRECTORY" --config "$SALUS_CONFIGURATION"
6 changes: 3 additions & 3 deletions lib/salus/scanners/npm_audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

module Salus::Scanners
class NPMAudit < NodeAudit
AUDIT_COMMAND = 'npm audit --json'.freeze
AUDIT_COMMAND = 'pnpm audit --json'.freeze

def should_run?
@repository.package_lock_json_present?
true
end

def version
shell_return = run_shell('npm audit --version')
shell_return = run_shell('pnpm --version')
Comment on lines +10 to +17

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it breaks npm support. Is that desired? I'd expect this to be additive.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I took a shortcut in the interest of time since we won't need npm support on our private fork. I can make it additive, but will take some time to figure out how to crawl up from the basedir to find the pnpm lockfile (instead of returning true) and all of the necessary places to hook into to provide pnpm as a standalone thing. Happy to do it if you think it's time well spent, but I was hoping the coinbase maintainers would do it in the issue I opened.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the specific purposes of our fork I think this is ok. It would be nice if we could submit a PR to Salus rather than just an issue, but I also understand that we have higher priority things to work on. I'm not super optimistic we'll be able to get off of our fork any time soon though 😢

# stdout looks like "6.14.8\n"
shell_return.stdout&.strip
end
Expand Down