Skip to content
Open
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
48 changes: 4 additions & 44 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,14 @@ name: Publish PR Preview
on:
pull_request:
types: [labeled]
workflow_dispatch:
inputs:
pr_number:
description: Pull request number to publish
required: true
type: string
publish_test_pypi:
description: Publish the Python package to TestPyPI
required: true
default: true
type: boolean
publish_docker:
description: Publish socketdev/cli:pr-<number> to Docker Hub
required: true
default: false
type: boolean
sdk_preview_version:
description: Optional exact TestPyPI socketdev prerelease for the Docker image
required: false
type: string

concurrency:
group: publish-pr-preview-${{ github.event.pull_request.number || github.run_id }}
group: publish-pr-preview-${{ github.event.pull_request.number }}
cancel-in-progress: false

jobs:
context:
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.label.name == 'publish-preview' ||
github.event.label.name == 'publish-docker-preview') &&
github.event.pull_request.head.repo.full_name == github.repository
Expand All @@ -48,28 +27,15 @@ jobs:
id: context
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
INPUT_PR_NUMBER: ${{ inputs.pr_number }}
WORKFLOW_REF: ${{ github.ref }}
with:
script: |
const rawPrNumber = context.eventName === 'workflow_dispatch'
? process.env.INPUT_PR_NUMBER
: process.env.EVENT_PR_NUMBER;
const rawPrNumber = process.env.EVENT_PR_NUMBER;
if (!/^[1-9][0-9]*$/.test(rawPrNumber || '')) {
core.setFailed('Pull request number must contain ASCII digits only.');
return;
}
if (context.eventName === 'workflow_dispatch') {
const defaultRef = `refs/heads/${process.env.DEFAULT_BRANCH}`;
if (process.env.WORKFLOW_REF !== defaultRef) {
core.setFailed(`Run manual previews from ${defaultRef}.`);
return;
}
}
const prNumber = Number(rawPrNumber);
if (!Number.isSafeInteger(prNumber)) {
core.setFailed('Pull request number is outside the supported range.');
Expand Down Expand Up @@ -162,9 +128,7 @@ jobs:

publish-package:
needs: [context, build]
if: >-
github.event.label.name == 'publish-preview' ||
(github.event_name == 'workflow_dispatch' && inputs.publish_test_pypi)
if: github.event.label.name == 'publish-preview'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
Expand Down Expand Up @@ -228,9 +192,7 @@ jobs:
publish-docker:
needs: [context, build]
if: >-
github.event.label.name == 'publish-docker-preview' ||
(github.event_name == 'workflow_dispatch' && inputs.publish_docker)
if: github.event.label.name == 'publish-docker-preview'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
Expand Down Expand Up @@ -274,8 +236,6 @@ jobs:
# arm64 layer builds under emulation, so expect roughly double the runtime.
platforms: linux/amd64,linux/arm64
tags: socketdev/cli:pr-${{ needs.context.outputs.pr_number }}
build-args: |
SDK_PREVIEW_VERSION=${{ inputs.sdk_preview_version }}

- name: Comment on pull request
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.15.11

### Security

- Removed the manual dispatch trigger from the pull request preview workflow. A
dispatch ran pull request code with write access to the default branch's
GitHub Actions cache. Previews are now published only from the
`publish-preview` and `publish-docker-preview` labels.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changelog narrates workflow incident

Low Severity

The 2.15.11 notes violate the user-facing changelog rule. They recount how manual dispatch ran pull request code against the default branch Actions cache, which is incident and workflow rationale rather than product, dashboard, or CI-log behavior. The published CLI is unchanged, so the Security heading overstates what this release does.

Fix in Cursor Fix in Web

Triggered by learned rule: CHANGELOG is user-facing — short bullets only

Reviewed by Cursor Bugbot for commit 0d0e97f. Configure here.


## 2.15.10

### Added
Expand Down
17 changes: 7 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,16 @@ needs testing:
`socketdev/cli:pr-<pull-request-number>` image to Docker Hub and adds or
updates a pull request comment with the image tag.

Both label-triggered and manually dispatched previews are limited to open pull
requests whose branches belong to this repository. Each label is handled as a
separate event, so applying both labels starts two workflow runs. Use manual
dispatch instead when both artifacts should be published in a single run.
Previews are limited to open pull requests whose branches belong to this
repository. Each label is handled as a separate event, so applying both labels
starts two workflow runs.

The workflow reacts when a label is added; pushing another commit while the
label remains on the pull request does not publish a new preview. To publish the
new pull request head or retry a failed publication, remove the relevant label
and apply it again.

Maintainers can also open **Actions > Publish PR Preview > Run workflow**, run
it from the repository's default branch, enter the pull request number, and
choose whether to publish to TestPyPI, Docker Hub, or both. When testing the CLI
against an SDK preview, enter the exact TestPyPI `socketdev` prerelease in
`sdk_preview_version`; publish the SDK preview first and allow time for
TestPyPI to expose it before starting the CLI Docker preview.
The workflow has no manual dispatch trigger. A dispatch from the default branch
would build pull request code with write access to the default branch's Actions
cache, so previews are only published from label events, which run in the pull
request's own cache scope.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "socketsecurity"
version = "2.15.10"
version = "2.15.11"
requires-python = ">= 3.11"
license = {"file" = "LICENSE"}
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__author__ = 'socket.dev'
__version__ = '2.15.10'
__version__ = '2.15.11'
USER_AGENT_NAME = 'socket-python-cli'
USER_AGENT = f'{USER_AGENT_NAME}/{__version__}'
26 changes: 15 additions & 11 deletions socketsecurity/fossa_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,28 @@ def _build_epss(props: dict[str, Any]) -> dict[str, Any]:
}


# CVSS base metrics, as (FOSSA metric name, Socket alert prop key).
_CVSS_METRIC_FIELDS = (
("Attack Vector", "attackVector"),
("Attack Complexity", "attackComplexity"),
("Privileges Required", "privilegesRequired"),
("User Interaction", "userInteraction"),
("Scope", "scope"),
("Confidentiality Impact", "confidentialityImpact"),
("Integrity Impact", "integrityImpact"),
("Availability Impact", "availabilityImpact"),
)


def _build_metrics(props: dict[str, Any]) -> list[dict[str, Any]]:
metrics = props.get("metrics")
if isinstance(metrics, list):
return metrics

metric_map = [
("Attack Vector", props.get("attackVector")),
("Attack Complexity", props.get("attackComplexity")),
("Privileges Required", props.get("privilegesRequired")),
("User Interaction", props.get("userInteraction")),
("Scope", props.get("scope")),
("Confidentiality Impact", props.get("confidentialityImpact")),
("Integrity Impact", props.get("integrityImpact")),
("Availability Impact", props.get("availabilityImpact")),
]
metric_values = ((name, props.get(key)) for name, key in _CVSS_METRIC_FIELDS)
return [
{"name": name, "value": value}
for name, value in metric_map
for name, value in metric_values
if value not in (None, "")
]

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.