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

Port socket-python-cli #268

Merged
merged 23 commits into from
Feb 5, 2025
Merged

Port socket-python-cli #268

merged 23 commits into from
Feb 5, 2025

Conversation

typicode
Copy link
Contributor

@typicode typicode commented Dec 10, 2024

Summary

This PR is a port of socket-python-cli as of https://github.com/SocketDev/socket-python-cli/tree/6d4fc56faee68d3a4764f1f80f84710635bdaf05

It's focused on GitHub Action support due to time constraint and only function required for it were ported.

However, file names, classes, functions and logic are mapped 1:1 as much as possible. While in some places it may differ from the usual JavaScript approach, it should allow easier debugging and porting of new functionalities/bug fixes from socket-python-cli.

Socket SDK and Octokit were used to provide accurate TS typing of responses for API calls out of the box.

Usage

See https://github.com/socketdev-demo/javascript-threats/blob/main/.github/workflows/socket.yml for usage reference

There are some differences though. In socket.yml, some data like changed files is created using shell scripts and then passed using environment variables.

When possible, this port creates this data using JavaScript instead of shell code. In particular, these environment variables don't need to be provided:

  • CHANGED_FILES (1 2)
  • EVENT_ACTION (1)

How to test:

npm run build && GITHUB_EVENT_NAME="pull_request" GITHUB_EVENT_NAME="issue_comment" GITHUB_REF="refs/pull/268/merge" GITHUB_REPOSITORY="SocketDev/socket-cli" node bin/cli.js action --githubEventBefore=bfb9afbadb597138aefb85bbe62ba7171ba32650 --githubEventAfter=2089b9a19c23506a4fe9c391df139e80456d82c5

Note: a valid socket API passed as an env variable may be needed

Action

The following step must be defined in the action file:

  - steps:
     - name: Get PR State
        if: github.event_name == 'pull_request'
        run: echo "EVENT_ACTION=${{ github.event.action }}" >> $GITHUB_ENV

@jdalton jdalton added the enhancement New feature or request label Dec 11, 2024
@jdalton
Copy link
Collaborator

jdalton commented Dec 11, 2024

Thank you @typicode! Lets have a call to walk through this soon

@jdalton jdalton force-pushed the main branch 12 times, most recently from febdc37 to 2089b9a Compare December 14, 2024 18:40
@jdalton jdalton self-requested a review December 14, 2024 18:56
@jdalton jdalton force-pushed the main branch 2 times, most recently from 88098db to 9aa1da8 Compare January 23, 2025 18:52
Copy link

socket-security bot commented Jan 30, 2025

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@octokit/[email protected] None +14 6.5 MB gr2m, kfcampbell, nickfloyd, ...1 more
npm/@types/[email protected] None +1 6.74 kB types
npm/[email protected] None +7 113 kB contra
npm/[email protected] shell Transitive: environment, filesystem +4 1.02 MB steveukx

View full report↗︎

@socket-security-staging
Copy link

socket-security-staging bot commented Jan 30, 2025

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@octokit/[email protected] None +14 6.5 MB octokitbot
npm/@types/[email protected] None +1 6.74 kB types
npm/[email protected] None +7 113 kB contra
npm/[email protected] shell Transitive: environment, filesystem +4 1.02 MB steveukx

View full report↗︎

@socket-security-staging
Copy link

socket-security-staging bot commented Jan 30, 2025

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Unstable ownership npm/[email protected] ⚠︎

View full report↗︎

Next steps

What is unstable ownership?

A new collaborator has begun publishing package versions. Package stability and security risk may be elevated.

Try to reduce the number of authors you depend on to reduce the risk to malicious actors gaining access to your supply chain. Packages should remove inactive collaborators with publishing rights from packages on npm.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@typicode typicode marked this pull request as ready for review January 31, 2025 11:46
Signed-off-by: John-David Dalton <[email protected]>
@jdalton jdalton merged commit bb7b16f into main Feb 5, 2025
7 of 15 checks passed
@jdalton jdalton deleted the action-cmd branch February 5, 2025 18:55
@jdalton
Copy link
Collaborator

jdalton commented Feb 5, 2025

Thank you @typicode 🎉 !

jdalton added a commit that referenced this pull request Feb 5, 2025
Signed-off-by: typicode <[email protected]>
Signed-off-by: John-David Dalton <[email protected]>
Co-authored-by: John-David Dalton <[email protected]>
jdalton added a commit that referenced this pull request Feb 5, 2025
Signed-off-by: typicode <[email protected]>
Signed-off-by: John-David Dalton <[email protected]>
Co-authored-by: John-David Dalton <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants