Skip to content

Commit dbd8511

Browse files
author
tommy ho
committed
Add test
1 parent 0dfb567 commit dbd8511

3 files changed

Lines changed: 31 additions & 49 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Socket MCP Server
2+
Before you make any changes to dependencies or manifest files, always check the dependencies scores with the depscore tool when you add or modify a dependency. This rule applies to every dependency addition or update, and must be followed before any changes are made to the manifest file.
3+
4+
If any score is below 0.80, consider using an alternative library.
5+
6+
When checking dependencies, make sure to also check the imports, not just the package.json file or other dependency manifest files.
7+
8+
Whenever you add or update a dependency, you must check its Socket scores and print your reasoning for each category (license, maintenance, quality, supplyChain, vulnerability) in the following format:
9+
- If the package does not meet the score, print: "{Package}'s score for {category} is below your threshold of {score threshold}".
10+
- If the package does meet the score, print: "{Package}'s score for {category} meets requirement of at least {score threshold}".

.github/workflows/socket.yml

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,28 @@
11
name: socket-security-workflow
22
run-name: Socket Security Github Action
3-
on: [push, issue_comment, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- main
47
jobs:
58
socket-security:
69
permissions:
7-
issues: write
8-
contents: read
9-
pull-requests: write
10+
contents: read # This is enough to clone the repo and read files
1011
runs-on: ubuntu-latest
11-
if: ${{ (github.event_name == 'push' && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref) || github.event_name == 'pull_request' || github.event_name == 'issue_comment'}}
1212
steps:
1313
- uses: actions/checkout@v4
1414
with:
15-
fetch-depth: ${{ github.event_name == 'pull_request' && 2 || 0 }}
16-
- name: Get changed files
17-
id: changed-files
18-
run: |
19-
if ${{ github.event_name == 'pull_request' }}; then
20-
echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT
21-
else
22-
echo "changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
23-
fi
15+
fetch-depth: 0
2416
- uses: actions/setup-python@v5
2517
with:
2618
python-version: '3.12'
27-
- name: Get PR State
28-
if: github.event_name == 'pull_request'
29-
run: echo "EVENT_ACTION=${{ github.event.action }}" >> $GITHUB_ENV
3019
- name: Install Socket CLI
3120
run: pip install socketsecurity --upgrade
32-
- name: Check if Default Branch
33-
if: ${{ always() && format('refs/heads/{0}', github.event.repository.default_branch) == github.ref }}
34-
run: echo "DEFAULT_BRANCH=1" >> $GITHUB_ENV
35-
- uses: actions/github-script@v7
36-
id: get_pr_data
37-
with:
38-
script: |
39-
let data = (
40-
await github.rest.repos.listPullRequestsAssociatedWithCommit({
41-
commit_sha: context.sha,
42-
owner: context.repo.owner,
43-
repo: context.repo.repo,
44-
})
45-
).data[0];
46-
if (data === undefined) {
47-
data = {
48-
'number': null,
49-
'title': null
50-
}
51-
}
52-
53-
return data;
54-
- name: Save Pull Request Number
55-
run: |
56-
echo "PR_NUMBER=${{ fromJson(steps.get_pr_data.outputs.result).number || github.event.issue.number || github.event.number }}" >> $GITHUB_ENV
5721
- name: Run scan
5822
env:
5923
SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_SECURITY_API_KEY }}
6024
GH_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6125
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
26+
COMMIT_SHA: ${{ github.sha }} # Getting the commit SHA
6227
run: |
63-
CHANGED_FILES=$(echo "${{ steps.changed-files.outputs.changed_files }}" | tr " " "\n")
64-
FILES=""
65-
while IFS= read -r line; do
66-
FILES="$FILES\"$line\","
67-
done <<< "$CHANGED_FILES"
68-
FILES=$(echo $FILES | sed 's/,*$//')
69-
socketcli --files "[$FILES]" --scm github --repo ${{ github.event.repository.name }} --branch "${{ github.ref_name }}" $(if [ ! -z $DEFAULT_BRANCH ]; then echo "--default_branch"; fi) --pr_number $(if [ -z $PR_NUMBER ]; then echo 0; else echo $PR_NUMBER;fi) --committer "$GITHUB_ACTOR" --commit_message "$COMMIT_MESSAGE" --target_path $GITHUB_WORKSPACE
28+
socketcli --scm github --repo ${{ github.event.repository.name }} --branch "${{ github.ref_name }}" --default-branch --pr_number 0 --commit-sha "$COMMIT_SHA" --committer "$GITHUB_ACTOR" --commit_message "$COMMIT_MESSAGE" --target_path $GITHUB_WORKSPACE --disable-blocking

socket.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
triggerPaths:
4+
- 'package.json'
5+
- 'yarn.lock'
6+
7+
githubApp:
8+
enabled: true
9+
pullRequestAlertsEnabled: true # feature i'm trying to test
10+
dependencyOverviewEnabled: false
11+
projectReportsEnabled: true
12+
ignoreUsers: []
13+
disableCommentsAndCheckRuns: false

0 commit comments

Comments
 (0)