-
Notifications
You must be signed in to change notification settings - Fork 131
[6.16.z] Fix template sync over SSH on IPv6 #20601
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
Open
Satellite-QE
wants to merge
1
commit into
6.16.z
Choose a base branch
from
cherry-pick-6.16.z-8cdc68402fd1ed8eed066a72aa62aaf8e883ec48
base: 6.16.z
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.
Open
[6.16.z] Fix template sync over SSH on IPv6 #20601
Satellite-QE
wants to merge
1
commit into
6.16.z
from
cherry-pick-6.16.z-8cdc68402fd1ed8eed066a72aa62aaf8e883ec48
+1
−1
Conversation
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
(cherry picked from commit 8cdc684)
Collaborator
Author
|
Contributor
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.
Hey - I've found 1 security issue, and left some high level feedback:
Security issues:
- Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option. (link)
General comments:
- The new
sudo -u foreman sh -c '...'command builds a single-quoted shell string inside a Python f-string; ifgit.hostnameorkey_pathever contain characters like single quotes or shell metacharacters this will break or become unsafe—consider passing arguments without extra shell interpolation (e.g., usingsudo -u foreman sh -cwith carefully escaped parameters or a helper that avoids manual quoting). - This change introduces a hard dependency on
sudoand theforemanuser being present on the target system; if this fixture is used in different environments, it may be safer to assert or detect their availability before running the command and fail fast with a clear error when they are missing.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `sudo -u foreman sh -c '...'` command builds a single-quoted shell string inside a Python f-string; if `git.hostname` or `key_path` ever contain characters like single quotes or shell metacharacters this will break or become unsafe—consider passing arguments without extra shell interpolation (e.g., using `sudo -u foreman sh -c` with carefully escaped parameters or a helper that avoids manual quoting).
- This change introduces a hard dependency on `sudo` and the `foreman` user being present on the target system; if this fixture is used in different environments, it may be safer to assert or detect their availability before running the command and fail fast with a clear error when they are missing.
## Individual Comments
### Comment 1
<location> `pytest_fixtures/component/templatesync.py:68-70` </location>
<code_context>
session_target_sat.execute(
f"sudo -u foreman sh -c 'ssh-keyscan -t rsa -p {git.ssh_port} {git.hostname} >> {key_path}/known_hosts'"
)
</code_context>
<issue_to_address>
**security (python.sqlalchemy.security.sqlalchemy-execute-raw-query):** Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.
*Source: opengrep*
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Member
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
6.16.z
Auto_Cherry_Picked
Automatically cherrypicked PR using GHA
AutoMerge_Cherry_Picked
The cherrypicked PRs of master PR would be automerged if all checks passing
No-CherryPick
PR doesnt need CherryPick to previous branches
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.
Cherrypick of PR: #20552
Problem Statement
Template sync tests that use SSH for transport are failing on IPv6 while on IPv4 they pass:
Further investigation showed that
ssh-keyscanis used with wrong parameter-4:Solution
Sanitize
ssh-keyscancommand:- don't always use ipv4, especially on ipv6-4sudo -u foreman ...-.ssh/known_hostsfile should be owned by userforemannotroot>> {key_path}/known_hosts-.ssh/known_hostsfile may contain multiple entries, append new entryRelated Issues
SAT-41275