Skip to content

Report portal ci#554

Closed
sshmulev wants to merge 6 commits into
osbuild:mainfrom
sshmulev:report_portal_ci
Closed

Report portal ci#554
sshmulev wants to merge 6 commits into
osbuild:mainfrom
sshmulev:report_portal_ci

Conversation

@sshmulev
Copy link
Copy Markdown
Collaborator

@sshmulev sshmulev commented Jun 1, 2026

No description provided.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a 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 2 issues, and left some high level feedback:

  • In get_instances_oci, values['source_details'][0]['source_id'] assumes source_details is a list, but OCIConfigBuilder defines it as a dict; consider accessing source_details defensively (supporting both shapes or aligning them) to avoid runtime key/index errors.
  • The heuristic in get_oci_username_by_instance_name (sanitized in tf_resource_name) can match multiple instances when names share substrings; consider using an exact or anchored match (e.g., full resource name or a clearer naming convention) to avoid returning the wrong username.
  • In ci/rp_merge.py all HTTP calls use verify=False, which disables TLS verification globally; consider making TLS verification configurable via a CLI flag or environment variable so production runs can keep certificate checks enabled.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `get_instances_oci`, `values['source_details'][0]['source_id']` assumes `source_details` is a list, but `OCIConfigBuilder` defines it as a dict; consider accessing `source_details` defensively (supporting both shapes or aligning them) to avoid runtime key/index errors.
- The heuristic in `get_oci_username_by_instance_name` (`sanitized in tf_resource_name`) can match multiple instances when names share substrings; consider using an exact or anchored match (e.g., full resource name or a clearer naming convention) to avoid returning the wrong username.
- In `ci/rp_merge.py` all HTTP calls use `verify=False`, which disables TLS verification globally; consider making TLS verification configurable via a CLI flag or environment variable so production runs can keep certificate checks enabled.

## Individual Comments

### Comment 1
<location path="ci/rp_merge.py" line_range="60" />
<code_context>
+    url = f"{rp_url}/api/v1/{project}/launch"
+    params = {"filter.has.attributeValue": group_token, "page.size": 50}
+    try:
+        resp = requests.get(url, headers=headers, params=params, verify=False, timeout=30)
+        resp.raise_for_status()
+        return resp.json().get("content", [])
</code_context>
<issue_to_address>
**🚨 issue (security):** Unconditional `verify=False` on HTTP requests weakens TLS security and should be controllable.

This call (and others in the script) hardcodes `verify=False` and suppresses `InsecureRequestWarning`, fully disabling TLS verification. Please make verification configurable (e.g., a `--insecure` flag or env var) with a secure default (`verify=True`), and consider supporting a custom CA bundle instead of always skipping verification.
</issue_to_address>

### Comment 2
<location path="test_suite/cloud/test_oci.py" line_range="6-13" />
<code_context>
+import pytest
+
+
+@pytest.fixture
+def instance_data_oci_web(host):
+    """
+    Fetch instance metadata from OCI IMDS (Instance Metadata Service).
+    """
+    oci_metadata_url = 'http://169.254.169.254/opc/v2/instance/'
+    command_to_run = f'curl -s -H "Authorization: Bearer Oracle" "{oci_metadata_url}"'
+    return json.loads(host.check_output(command_to_run))
+
+
</code_context>
<issue_to_address>
**suggestion (testing):** Make the OCI metadata fixture more resilient to temporary IMDS failures or malformed responses

This fixture currently assumes `curl` always succeeds and returns valid JSON, so any transient IMDS issue (network/rate limiting/partial response) will hard-fail all dependent tests.

Please consider:
- Wrapping `host.check_output` / `json.loads` in try/except and using `pytest.skip` or `xfail` with a clear message when IMDS is unreachable or returns bad JSON.
- Adding a short timeout to curl (e.g. `curl -s --max-time 2 ...`) to avoid a hung IMDS call blocking the test run.

That way, these tests stay focused on configuration validation instead of being fragile to infra noise.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread ci/rp_merge.py
url = f"{rp_url}/api/v1/{project}/launch"
params = {"filter.has.attributeValue": group_token, "page.size": 50}
try:
resp = requests.get(url, headers=headers, params=params, verify=False, timeout=30)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 issue (security): Unconditional verify=False on HTTP requests weakens TLS security and should be controllable.

This call (and others in the script) hardcodes verify=False and suppresses InsecureRequestWarning, fully disabling TLS verification. Please make verification configurable (e.g., a --insecure flag or env var) with a secure default (verify=True), and consider supporting a custom CA bundle instead of always skipping verification.

Comment thread test_suite/cloud/test_oci.py
@sshmulev sshmulev closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant