-
Notifications
You must be signed in to change notification settings - Fork 10
Install the pinned reachability engine in the Docker image #345
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
Draft
lelia
wants to merge
1
commit into
main
Choose a base branch
from
lelia/ce-431-coana-pin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| __author__ = 'socket.dev' | ||
| __version__ = '2.7.1' | ||
| __version__ = '2.7.2' | ||
| USER_AGENT = f'SocketPythonCLI/{__version__}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """Guards the image's ``@coana-tech/cli`` install against drifting from the runtime pin. | ||
|
|
||
| The launcher asks npx for ``@coana-tech/cli@DEFAULT_COANA_CLI_VERSION``, and npx reuses the | ||
| image's global install only when the versions match; on a mismatch it downloads the engine | ||
| again on every scan. The Dockerfile therefore derives the version from ``reachability.py`` | ||
| with a ``sed`` expression instead of repeating it. These tests run that expression against | ||
| the real source, so a reformatted constant or a broken expression fails here rather than | ||
| silently producing a mismatched image. | ||
| """ | ||
|
|
||
| import re | ||
| import subprocess | ||
| from pathlib import Path | ||
|
|
||
| from socketsecurity.core.tools.reachability import DEFAULT_COANA_CLI_VERSION | ||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parents[2] | ||
| DOCKERFILE = REPO_ROOT / "Dockerfile" | ||
| REACHABILITY_SOURCE = ( | ||
| REPO_ROOT / "socketsecurity" / "core" / "tools" / "reachability.py" | ||
| ) | ||
|
|
||
|
|
||
| def _dockerfile_sed_expression() -> str: | ||
| """Return the pin-extraction expression the Dockerfile runs.""" | ||
| match = re.search( | ||
| r"sed -n '(s/\^DEFAULT_COANA_CLI_VERSION[^']*)'", DOCKERFILE.read_text() | ||
| ) | ||
| assert match, "Dockerfile no longer extracts DEFAULT_COANA_CLI_VERSION with sed" | ||
| return match.group(1) | ||
|
|
||
|
|
||
| def test_dockerfile_expression_extracts_the_pinned_version(): | ||
| extracted = subprocess.run( | ||
| ["sed", "-n", _dockerfile_sed_expression(), str(REACHABILITY_SOURCE)], | ||
| capture_output=True, | ||
| text=True, | ||
| check=True, | ||
| ).stdout.strip() | ||
| assert extracted == DEFAULT_COANA_CLI_VERSION | ||
|
|
||
|
|
||
| def test_dockerfile_never_installs_coana_unpinned(): | ||
| install_lines = [ | ||
| line for line in DOCKERFILE.read_text().splitlines() if "npm install" in line | ||
| ] | ||
| assert install_lines, "Dockerfile no longer installs anything with npm" | ||
| for line in install_lines: | ||
| if "@coana-tech/cli" in line: | ||
| assert "@coana-tech/cli@" in line, f"unpinned coana install: {line.strip()}" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stable build ignores tag checkout
Medium Severity
The new tag checkout does not feed the image build.
docker/build-push-actionstill uses the workflow Git context from the dispatch branch, so theDockerfileandreachability.pycome from that branch whileCLI_VERSIONinstalls the requested wheel. Rebuilding an older stable after main has moved recreates the pin mismatch.Additional Locations (1)
.github/workflows/docker-stable.yml#L41-L51Reviewed by Cursor Bugbot for commit 21a802d. Configure here.