Resolve NVSkills Tier 1 security findings in cuopt-server-api-python - #1677
Resolve NVSkills Tier 1 security findings in cuopt-server-api-python#1677ramakrishnap-nv wants to merge 11 commits into
Conversation
|
/nvskills-ci |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe skill documentation adds deployment, REST limitation, troubleshooting, and client guidance. Bundled clients use ChangescuOpt Server API
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
CI Test Summary✅ All 31 test job(s) passed. |
|
/nvskills-ci |
|
/nvskills-ci |
|
/nvskills-ci |
4 similar comments
|
/nvskills-ci |
|
/nvskills-ci |
|
/nvskills-ci |
|
/nvskills-ci |
|
/nvskills-ci |
1 similar comment
|
/nvskills-ci |
|
/nvskills-ci |
1 similar comment
|
/nvskills-ci |
|
/nvskills-ci |
|
/nvskills-ci |
1 similar comment
|
/nvskills-ci |
…thon The NVSkills CI gate blocked this branch with 15 critical Security Scan errors, all instances of one taint rule (TT3): the asset clients sourced the server base URL from os.environ.get, which the scanner classifies as a credential/environment source flowing into a requests network sink. Three sinks in each of the five client.py scripts produced the 15 errors. Replace the CUOPT_SERVER_URL environment variable with an argparse --server flag (same default, http://localhost:8000), which removes the tainted source without losing configurability. Also address the accompanying advisories: - set an explicit timeout on every request (Bandit B113, 10 findings) - validate the server-supplied reqId before interpolating it into the polling URL (TT2, 4 findings) - recommend latest-cu12 / latest-cu13 over the CUDA+Python-specific tags; the py3.13 line no longer receives builds, so latest-cuda12.9-py3.13 was both mutable and stale - move the frontmatter version key under metadata - add Purpose, Prerequisites, Instructions, Examples, Limitations, and Troubleshooting sections Expand the eval set from 1 to 8 cases covering LP and MILP payloads, QP being unavailable over REST, 422 debugging, Docker deployment, client hardening, and the bundled assets. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
|
/nvskills-ci |
…atter The previous commit moved the SKILL.md frontmatter `version` key under `metadata` to satisfy an NVSkills schema advisory. That collides with the repo's own `sync-skills-version` pre-commit hook, which requires a root-level `version:` in every skills/*/SKILL.md and re-inserts one after `name:` when it is absent — modifying the file and failing check-style. The repo hook is a hard CI failure; the NVSkills item is a non-blocking MEDIUM advisory, so the root-level key wins. Note that `sync-skills-version` and `validate-skills` only run when VERSION or skills/ paths are in the file list, so `pre-commit run --files <changed>` does not exercise them. CI runs `pre-commit run --all-files`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Ramakrishna Prabhu <ramakrishnap@nvidia.com>
|
/nvskills-ci |
There was a problem hiding this comment.
Actionable comments posted: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
skills/cuopt-server-api-python/assets/pdp_basic/client.py (1)
19-98: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winAdd pytest coverage for the new client behavior.
This PR adds
--serverparsing, request timeouts, and reqId validation. Add mocked unit tests for server forwarding, timeout arguments, accepted reqIds, rejected reqIds, and unavailable-server exit behavior.
skills/cuopt-server-api-python/assets/pdp_basic/client.py#L19-L98: add coverage for PDP client behavior.skills/cuopt-server-api-python/assets/vrp_basic/client.py#L24-L105: add coverage for VRP-with-time-windows client behavior.skills/cuopt-server-api-python/assets/vrp_simple/client.py#L22-L99: add coverage for simple-VRP client behavior.As per coding guidelines, “Contributions implementing features or bug fixes must include unit tests.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@skills/cuopt-server-api-python/assets/pdp_basic/client.py` around lines 19 - 98, Add pytest coverage for the client behavior in skills/cuopt-server-api-python/assets/pdp_basic/client.py (lines 19-98), skills/cuopt-server-api-python/assets/vrp_basic/client.py (lines 24-105), and skills/cuopt-server-api-python/assets/vrp_simple/client.py (lines 22-99). Mock HTTP requests and verify --server forwarding, request timeout arguments, accepted and rejected reqId validation, and clean exit when the server is unavailable; cover each client’s main flow without making real network calls.Source: Coding guidelines
skills/cuopt-server-api-python/assets/lp_basic/client.py (1)
24-91: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winHandle non-string
reqIdvalues before validation and add pytest coverage.
REQ_ID_PATTERN.fullmatch(req_id)raisesTypeErrorforNoneor numeric IDs. Check the type before validation so malformed responses exit with the intended error. Cover both clients, including server arguments, request timeouts, and malformed string and non-string IDs.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@skills/cuopt-server-api-python/assets/lp_basic/client.py` around lines 24 - 91, Validate that req_id is a string before calling REQ_ID_PATTERN.fullmatch in both clients’ main request flows, preserving the existing error message and exit behavior for malformed string and non-string IDs. Add pytest coverage for both client modules, including server argument handling, request timeouts, malformed string IDs, and None or numeric reqId values; update skills/cuopt-server-api-python/assets/lp_basic/client.py lines 24-91 and skills/cuopt-server-api-python/assets/milp_basic/client.py lines 22-89 as the affected sites.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/cuopt-server-api-python/assets/lp_basic/client.py`:
- Around line 24-43: Update parse_args, server_ok, and main in
skills/cuopt-server-api-python/assets/lp_basic/client.py (lines 24-43) and
skills/cuopt-server-api-python/assets/milp_basic/client.py (lines 22-41) with
precise type hints and meaningful API docstrings covering parameters, return
values, and any SystemExit conditions. Keep both client implementations
consistent.
- Around line 81-84: Validate the parsed JSON response and its reqId value
before calling REQ_ID_PATTERN.fullmatch, handling non-object responses, missing
reqId fields, and non-string values through the existing unexpected-reqId error
path. Apply the same update to the response handling in
skills/cuopt-server-api-python/assets/lp_basic/client.py:81-84 and
skills/cuopt-server-api-python/assets/milp_basic/client.py:79-82; preserve
validation of well-formed string reqId values.
In `@skills/cuopt-server-api-python/assets/pdp_basic/client.py`:
- Around line 19-34: Add parameter and return type annotations plus meaningful
docstrings to the public parse_args and server_ok functions in
skills/cuopt-server-api-python/assets/pdp_basic/client.py:19-34,
skills/cuopt-server-api-python/assets/vrp_basic/client.py:24-39, and
skills/cuopt-server-api-python/assets/vrp_simple/client.py:22-37; document
parameters, return values, and raised errors while preserving their existing
behavior.
- Around line 29-34: Update server_ok in
skills/cuopt-server-api-python/assets/pdp_basic/client.py (lines 29-34),
skills/cuopt-server-api-python/assets/vrp_basic/client.py (lines 34-39), and
skills/cuopt-server-api-python/assets/vrp_simple/client.py (lines 32-37) to
re-raise requests.exceptions.SSLError before catching
requests.exceptions.ConnectionError, and catch only connection failures and
timeouts. Do not catch InvalidURL or other configuration errors; apply the same
change to the corresponding server_ok implementations in milp_basic and
lp_basic.
In `@skills/cuopt-server-api-python/assets/README.md`:
- Line 14: Before merging, amend or rebase the PR commits so every commit has a
Signed-off-by trailer, preserve or add the required NVSkills validation
signature commit after the final push, and wait for NVSkills CI to pass before
merging into main.
In `@skills/cuopt-server-api-python/SKILL.md`:
- Around line 16-18: Update the introductory description in the cuOpt Server
skill to remove the incorrect claim that no separate C API exists. State that
the REST server accepts HTTP clients in any language, and that cuOpt separately
provides a C API for direct LP, QP, and MILP use.
- Around line 118-121: Correct the REST security guidance in
skills/cuopt-server-api-python/SKILL.md at lines 118-121 to state that
cuopt_server.cuopt_service supports TLS via --ssl-certfile and --ssl-keyfile,
while providing no built-in authentication. Update the corresponding evaluation
wording in skills/cuopt-server-api-python/evals/evals.json at lines 77-86 to
require the same distinction; both sites need direct changes.
---
Outside diff comments:
In `@skills/cuopt-server-api-python/assets/lp_basic/client.py`:
- Around line 24-91: Validate that req_id is a string before calling
REQ_ID_PATTERN.fullmatch in both clients’ main request flows, preserving the
existing error message and exit behavior for malformed string and non-string
IDs. Add pytest coverage for both client modules, including server argument
handling, request timeouts, malformed string IDs, and None or numeric reqId
values; update skills/cuopt-server-api-python/assets/lp_basic/client.py lines
24-91 and skills/cuopt-server-api-python/assets/milp_basic/client.py lines 22-89
as the affected sites.
In `@skills/cuopt-server-api-python/assets/pdp_basic/client.py`:
- Around line 19-98: Add pytest coverage for the client behavior in
skills/cuopt-server-api-python/assets/pdp_basic/client.py (lines 19-98),
skills/cuopt-server-api-python/assets/vrp_basic/client.py (lines 24-105), and
skills/cuopt-server-api-python/assets/vrp_simple/client.py (lines 22-99). Mock
HTTP requests and verify --server forwarding, request timeout arguments,
accepted and rejected reqId validation, and clean exit when the server is
unavailable; cover each client’s main flow without making real network calls.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 41630a42-64fe-4f91-9105-19f25c053ca6
📒 Files selected for processing (13)
skills/cuopt-server-api-python/SKILL.mdskills/cuopt-server-api-python/assets/README.mdskills/cuopt-server-api-python/assets/lp_basic/README.mdskills/cuopt-server-api-python/assets/lp_basic/client.pyskills/cuopt-server-api-python/assets/milp_basic/README.mdskills/cuopt-server-api-python/assets/milp_basic/client.pyskills/cuopt-server-api-python/assets/pdp_basic/README.mdskills/cuopt-server-api-python/assets/pdp_basic/client.pyskills/cuopt-server-api-python/assets/vrp_basic/README.mdskills/cuopt-server-api-python/assets/vrp_basic/client.pyskills/cuopt-server-api-python/assets/vrp_simple/README.mdskills/cuopt-server-api-python/assets/vrp_simple/client.pyskills/cuopt-server-api-python/evals/evals.json
| def parse_args(): | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument( | ||
| "--server", | ||
| default=DEFAULT_SERVER, | ||
| help=f"cuOpt server base URL (default: {DEFAULT_SERVER})", | ||
| ) | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| def server_ok(server): | ||
| try: | ||
| r = requests.get(f"{SERVER}/cuopt/health", timeout=2) | ||
| r = requests.get(f"{server}/cuopt/health", timeout=2) | ||
| return r.status_code == 200 | ||
| except Exception: | ||
| return False | ||
|
|
||
|
|
||
| def main(): | ||
| if not server_ok(): | ||
| server = parse_args().server |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python - <<'PY'
import ast
from pathlib import Path
paths = [
Path("skills/cuopt-server-api-python/assets/lp_basic/client.py"),
Path("skills/cuopt-server-api-python/assets/milp_basic/client.py"),
]
for path in paths:
tree = ast.parse(path.read_text())
for node in tree.body:
if isinstance(node, ast.FunctionDef) and not node.name.startswith("_"):
print(
f"{path}:{node.lineno} {node.name}: "
f"returns={node.returns is not None}, "
f"docstring={ast.get_docstring(node) is not None}"
)
PYRepository: NVIDIA/cuopt
Length of output: 760
🏁 Script executed:
#!/bin/bash
set -euo pipefail
for path in \
skills/cuopt-server-api-python/assets/lp_basic/client.py \
skills/cuopt-server-api-python/assets/milp_basic/client.py
do
echo "=== $path ==="
wc -l "$path"
sed -n '1,110p' "$path"
done
echo "=== related tests and call sites ==="
rg -n --glob '*.py' 'parse_args|server_ok|main\(' \
skills/cuopt-server-api-pythonRepository: NVIDIA/cuopt
Length of output: 9213
Add type hints and API docstrings to the new public functions.
Both client files define parse_args, server_ok, and main without type hints or meaningful docstrings. Document parameters, return values, and SystemExit conditions where applicable.
skills/cuopt-server-api-python/assets/lp_basic/client.py#L24-L43skills/cuopt-server-api-python/assets/milp_basic/client.py#L22-L41
🧰 Tools
🪛 ast-grep (0.45.1)
[warning] 35-35: Request-controlled URL passed to requests; validate against an allowlist to prevent SSRF.
Context: requests.get(f"{server}/cuopt/health", timeout=2)
Note: [CWE-918] Server-Side Request Forgery (SSRF).
(ssrf-requests)
🪛 Ruff (0.16.1)
[warning] 38-38: Do not catch blind exception: Exception
(BLE001)
📍 Affects 2 files
skills/cuopt-server-api-python/assets/lp_basic/client.py#L24-L43(this comment)skills/cuopt-server-api-python/assets/milp_basic/client.py#L22-L41
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/assets/lp_basic/client.py` around lines 24 -
43, Update parse_args, server_ok, and main in
skills/cuopt-server-api-python/assets/lp_basic/client.py (lines 24-43) and
skills/cuopt-server-api-python/assets/milp_basic/client.py (lines 22-41) with
precise type hints and meaningful API docstrings covering parameters, return
values, and any SystemExit conditions. Keep both client implementations
consistent.
Source: Coding guidelines
| req_id = response.json()["reqId"] | ||
| if not REQ_ID_PATTERN.fullmatch(req_id): | ||
| print(f"Unexpected reqId from server: {req_id!r}") | ||
| sys.exit(1) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- lp_basic/client.py ---'
cat -n skills/cuopt-server-api-python/assets/lp_basic/client.py | sed -n '1,130p'
printf '%s\n' '--- milp_basic/client.py ---'
cat -n skills/cuopt-server-api-python/assets/milp_basic/client.py | sed -n '1,130p'
printf '%s\n' '--- related reqId handling and tests ---'
rg -n --glob '*.py' --glob '*.md' --glob '*.yaml' --glob '*.yml' 'reqId|REQ_ID_PATTERN|lp_basic|milp_basic' skills python cpp 2>/dev/null | head -240Repository: NVIDIA/cuopt
Length of output: 34067
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- validation guidance ---'
cat -n skills/cuopt-server-api-python/SKILL.md | sed -n '62,100p'
printf '%s\n' '--- server response and request-id generation ---'
cat -n python/cuopt_server/cuopt_server/webserver.py | sed -n '770,800p'
cat -n python/cuopt_server/cuopt_server/utils/job_queue.py | sed -n '820,855p'
cat -n python/cuopt_server/cuopt_server/utils/job_queue.py | sed -n '1015,1042p'
printf '%s\n' '--- standalone behavior probe ---'
python3 - <<'PY'
import re
pattern = re.compile(r"[A-Za-z0-9_-]{1,64}")
def current(payload):
req_id = payload["reqId"]
return pattern.fullmatch(req_id)
def proposed(payload):
req_id = payload.get("reqId") if isinstance(payload, dict) else None
return not isinstance(req_id, str) or pattern.fullmatch(req_id) is None
cases = [
("missing key", {}),
("non-object JSON", []),
("null", {"reqId": None}),
("integer", {"reqId": 7}),
("valid string", {"reqId": "abc-123"}),
("invalid string", {"reqId": "abc/123"}),
]
for name, payload in cases:
try:
result = current(payload)
current_result = f"returns {result is not None}"
except Exception as exc:
current_result = f"raises {type(exc).__name__}"
try:
result = proposed(payload)
proposed_result = f"rejects={result}"
except Exception as exc:
proposed_result = f"raises {type(exc).__name__}"
print(f"{name}: current={current_result}; proposed={proposed_result}")
PY
printf '%s\n' '--- tests or fixtures for the two client assets ---'
find skills/cuopt-server-api-python -type f | sort | rg '(^|/)(test|tests|fixtures?)(/|_|\.|$)|client\.py$' | head -120Repository: NVIDIA/cuopt
Length of output: 6222
Handle missing and non-string reqId values.
If the JSON response is not an object, lacks reqId, or contains a non-string reqId, validate it before calling REQ_ID_PATTERN.fullmatch. Otherwise, the client raises KeyError or TypeError instead of using the existing error path in skills/cuopt-server-api-python/assets/lp_basic/client.py and skills/cuopt-server-api-python/assets/milp_basic/client.py.
📍 Affects 2 files
skills/cuopt-server-api-python/assets/lp_basic/client.py#L81-L84(this comment)skills/cuopt-server-api-python/assets/milp_basic/client.py#L79-L82
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/assets/lp_basic/client.py` around lines 81 -
84, Validate the parsed JSON response and its reqId value before calling
REQ_ID_PATTERN.fullmatch, handling non-object responses, missing reqId fields,
and non-string values through the existing unexpected-reqId error path. Apply
the same update to the response handling in
skills/cuopt-server-api-python/assets/lp_basic/client.py:81-84 and
skills/cuopt-server-api-python/assets/milp_basic/client.py:79-82; preserve
validation of well-formed string reqId values.
| def parse_args(): | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument( | ||
| "--server", | ||
| default=DEFAULT_SERVER, | ||
| help=f"cuOpt server base URL (default: {DEFAULT_SERVER})", | ||
| ) | ||
| return parser.parse_args() | ||
|
|
||
|
|
||
| def server_ok(server): | ||
| try: | ||
| r = requests.get(f"{SERVER}/cuopt/health", timeout=2) | ||
| r = requests.get(f"{server}/cuopt/health", timeout=2) | ||
| return r.status_code == 200 | ||
| except Exception: | ||
| return False |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Add type hints and docstrings to the new public functions.
The new parse_args and server_ok functions are public module APIs. Add parameter and return annotations. Add docstrings that describe parameters, return values, and raised errors.
skills/cuopt-server-api-python/assets/pdp_basic/client.py#L19-L34: annotate and documentparse_argsandserver_ok.skills/cuopt-server-api-python/assets/vrp_basic/client.py#L24-L39: annotate and documentparse_argsandserver_ok.skills/cuopt-server-api-python/assets/vrp_simple/client.py#L22-L37: annotate and documentparse_argsandserver_ok.
As per coding guidelines, “Require type hints on new public Python functions and classes” and “Document new public Python APIs with meaningful docstring content.”
🧰 Tools
🪛 ast-grep (0.45.1)
[warning] 30-30: Request-controlled URL passed to requests; validate against an allowlist to prevent SSRF.
Context: requests.get(f"{server}/cuopt/health", timeout=2)
Note: [CWE-918] Server-Side Request Forgery (SSRF).
(ssrf-requests)
🪛 Ruff (0.16.1)
[warning] 33-33: Do not catch blind exception: Exception
(BLE001)
📍 Affects 3 files
skills/cuopt-server-api-python/assets/pdp_basic/client.py#L19-L34(this comment)skills/cuopt-server-api-python/assets/vrp_basic/client.py#L24-L39skills/cuopt-server-api-python/assets/vrp_simple/client.py#L22-L37
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/assets/pdp_basic/client.py` around lines 19 -
34, Add parameter and return type annotations plus meaningful docstrings to the
public parse_args and server_ok functions in
skills/cuopt-server-api-python/assets/pdp_basic/client.py:19-34,
skills/cuopt-server-api-python/assets/vrp_basic/client.py:24-39, and
skills/cuopt-server-api-python/assets/vrp_simple/client.py:22-37; document
parameters, return values, and raised errors while preserving their existing
behavior.
Source: Coding guidelines
| def server_ok(server): | ||
| try: | ||
| r = requests.get(f"{SERVER}/cuopt/health", timeout=2) | ||
| r = requests.get(f"{server}/cuopt/health", timeout=2) | ||
| return r.status_code == 200 | ||
| except Exception: | ||
| return False |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
For the Requests version used by this repository, which exception classes distinguish TLS certificate failures and invalid URLs from connection failures and timeouts?
💡 Result:
In the Requests library, the following exception classes are used to distinguish these scenarios: 1. TLS Certificate Failures: The requests.exceptions.SSLError class is used [1]. It is a subclass of requests.exceptions.ConnectionError [1]. 2. Invalid URLs: The requests.exceptions.InvalidURL class is used [2][3]. This is a subclass of requests.exceptions.RequestException (and also inherits from ValueError) [2][3]. 3. Connection Failures: The requests.exceptions.ConnectionError class is used for general connection issues [4][1]. 4. Timeouts: The requests.exceptions.Timeout class is the base exception for timeouts [5][2]. It is a subclass of requests.exceptions.RequestException [5][3]. Catching requests.exceptions.Timeout will catch both requests.exceptions.ConnectTimeout and requests.exceptions.ReadTimeout errors [5][4].
Citations:
- 1: https://github.com/psf/requests/blob/main/src/requests/exceptions.py
- 2: https://requests.readthedocs.io/en/latest/_modules/requests/exceptions/
- 3: https://requests.readthedocs.io/en/stable/_modules/requests/exceptions/
- 4: https://requests.readthedocs.io/en/latest/api/?highlight=exceptions
- 5: https://docs.python-requests.org/en/latest/_modules/requests/exceptions/
🏁 Script executed:
#!/bin/bash
set -eu
for f in \
skills/cuopt-server-api-python/assets/pdp_basic/client.py \
skills/cuopt-server-api-python/assets/vrp_basic/client.py \
skills/cuopt-server-api-python/assets/vrp_simple/client.py
do
echo "===== $f ====="
wc -l "$f"
cat -n "$f"
done
echo "===== Requests references and tests ====="
rg -n --hidden -S \
'requests(\[|[<>=!~]|$)|server_ok|cuopt/health|SSLError|InvalidURL|ConnectTimeout|ReadTimeout' \
--glob '!**/.git/**' \
--glob '!**/node_modules/**' \
--glob '!**/dist/**' \
.
echo "===== candidate dependency files ====="
git ls-files | rg '(^|/)(requirements[^/]*|pyproject\.toml|setup\.cfg|setup\.py|environment[^/]*|Pipfile|.*\.lock)$' || trueRepository: NVIDIA/cuopt
Length of output: 27011
🏁 Script executed:
#!/bin/bash
set -eu
echo "===== all server_ok implementations ====="
rg -n -U -A8 -B2 'def server_ok\(server\):' skills/cuopt-server-api-python/assets
echo "===== all callers ====="
rg -n -A6 -B2 'if not server_ok\(server\)' skills/cuopt-server-api-python/assets
echo "===== Requests dependency declarations ====="
for f in dependencies.yaml conda/environments/all_cuda-133_arch-aarch64.yaml conda/environments/all_cuda-133_arch-x86_64.yaml conda/environments/all_cuda-129_arch-x86_64.yaml conda/environments/all_cuda-129_arch-aarch64.yaml python/cuopt_self_hosted/pyproject.toml
do
if [ -f "$f" ]; then
echo "===== $f ====="
rg -n -A3 -B3 'requests' "$f" || true
fi
done
echo "===== skill asset tests ====="
git ls-files skills/cuopt-server-api-python | rg '(^|/)(test[^/]*|tests?/|.*test.*)' || trueRepository: NVIDIA/cuopt
Length of output: 10459
🏁 Script executed:
#!/bin/bash
set -eu
python3 - <<'PY'
try:
import requests
except ImportError as exc:
print(f"requests unavailable: {exc}")
raise SystemExit(0)
classes = {
"SSLError": requests.exceptions.SSLError,
"InvalidURL": requests.exceptions.InvalidURL,
"ConnectionError": requests.exceptions.ConnectionError,
"Timeout": requests.exceptions.Timeout,
}
for name, cls in classes.items():
print(name, cls.__module__, cls.__mro__)
cases = {
"invalid_url": "not a URL",
"missing_scheme": "localhost:8000",
"unsupported_scheme": "ftp://localhost:8000",
}
for name, url in cases.items():
try:
requests.get(url, timeout=0.001)
except Exception as exc:
print("case", name, type(exc).__module__, type(exc).__name__)
else:
print("case", name, "no exception")
PYRepository: NVIDIA/cuopt
Length of output: 199
Narrow the health-check exception handling in all five clients.
Re-raise requests.exceptions.SSLError before catching requests.exceptions.ConnectionError, because SSLError subclasses ConnectionError. Catch only connection failures and timeouts. Do not catch requests.exceptions.InvalidURL or other URL configuration errors. Otherwise, main exits 0 and reports a TLS or URL configuration failure as “Server not running, skipping.”
Apply this to pdp_basic, vrp_basic, vrp_simple, milp_basic, and lp_basic.
🧰 Tools
🪛 ast-grep (0.45.1)
[warning] 30-30: Request-controlled URL passed to requests; validate against an allowlist to prevent SSRF.
Context: requests.get(f"{server}/cuopt/health", timeout=2)
Note: [CWE-918] Server-Side Request Forgery (SSRF).
(ssrf-requests)
🪛 Ruff (0.16.1)
[warning] 33-33: Do not catch blind exception: Exception
(BLE001)
📍 Affects 3 files
skills/cuopt-server-api-python/assets/pdp_basic/client.py#L29-L34(this comment)skills/cuopt-server-api-python/assets/vrp_basic/client.py#L34-L39skills/cuopt-server-api-python/assets/vrp_simple/client.py#L32-L37
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/assets/pdp_basic/client.py` around lines 29 -
34, Update server_ok in
skills/cuopt-server-api-python/assets/pdp_basic/client.py (lines 29-34),
skills/cuopt-server-api-python/assets/vrp_basic/client.py (lines 34-39), and
skills/cuopt-server-api-python/assets/vrp_simple/client.py (lines 32-37) to
re-raise requests.exceptions.SSLError before catching
requests.exceptions.ConnectionError, and catch only connection failures and
timeouts. Do not catch InvalidURL or other configuration errors; apply the same
change to the corresponding server_ok implementations in milp_basic and
lp_basic.
Source: Linters/SAST tools
|
|
||
| Start server: `python -m cuopt_server.cuopt_service --ip 0.0.0.0 --port 8000` | ||
| Env: `CUOPT_SERVER_URL` (default `http://localhost:8000`). | ||
| Server URL: `--server` (default `http://localhost:8000`). |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
git log --format='%H%n%B%n---' main..HEADRepository: NVIDIA/cuopt
Length of output: 2389
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- repository state ---'
git rev-parse --show-toplevel
git branch --show-current
git rev-parse HEAD
git remote -v
printf '%s\n' '--- commits unique to HEAD from main ---'
git log --reverse --format='%H%x09%an%x09%ae%x09%s%x09%(trailers:key=Signed-off-by,valueonly)' main..HEAD
printf '%s\n' '--- relevant history across all refs ---'
git log --all --format='%H%x09%ad%x09%an%x09%s' --date=short \
--grep='NVSkills\|signature\|validation' -i -n 30
printf '%s\n' '--- refs and recent branch tips ---'
git show-ref --heads --tags | tail -40Repository: NVIDIA/cuopt
Length of output: 5965
🏁 Script executed:
#!/bin/bash
set -euo pipefail
if command -v gh >/dev/null 2>&1; then
printf '%s\n' '--- GitHub CLI availability ---'
gh --version | head -1
printf '%s\n' '--- pull request metadata ---'
gh pr view --json number,baseRefName,headRefName,state,commits,statusCheckRollup \
--jq '{number,baseRefName,headRefName,state,commits: [.commits[] | {oid,message,authors}],checks: [.statusCheckRollup[] | {name,status,conclusion,detailsUrl}]}'
else
printf '%s\n' 'gh is not available; pull request metadata cannot be queried here'
fiRepository: NVIDIA/cuopt
Length of output: 316
🏁 Script executed:
#!/bin/bash
set -euo pipefail
repo='NVIDIA/cuopt'
sha='592c7b83da79cb84870186aca958c1018c5cf22f'
printf '%s\n' '--- pull requests for HEAD commit ---'
gh api -H 'Accept: application/vnd.github+json' \
"repos/${repo}/commits/${sha}/pulls" \
--jq '.[] | {number,title,state,base:.base.ref,head:.head.ref,headSha:.head.sha,merged_at}'
printf '%s\n' '--- commit status ---'
gh api -H 'Accept: application/vnd.github+json' \
"repos/${repo}/commits/${sha}/status" \
--jq '{state, statuses: [.statuses[] | {context,state,description,target_url}]}'
printf '%s\n' '--- check runs ---'
gh api -H 'Accept: application/vnd.github+json' \
"repos/${repo}/commits/${sha}/check-runs?per_page=100" \
--jq '{total_count,check_runs: [.check_runs[] | {name,status,conclusion,started_at,completed_at,details_url}]}'Repository: NVIDIA/cuopt
Length of output: 7149
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- complete commit messages and trailers for commits unique to HEAD ---'
git log --reverse --format='%H%x09%P%x09%an%x09%ae%x09%s%n%B%n---' main..HEAD
printf '%s\n' '--- raw commit headers for merge commits unique to HEAD ---'
for sha in $(git log --format='%H' --merges main..HEAD); do
git show -s --format=raw "$sha"
printf '%s\n' '---'
doneRepository: NVIDIA/cuopt
Length of output: 10218
🏁 Script executed:
#!/bin/bash
set -euo pipefail
repo='NVIDIA/cuopt'
pr=1677
printf '%s\n' '--- PR commits and DCO trailers ---'
gh api -H 'Accept: application/vnd.github+json' \
"repos/${repo}/pulls/${pr}/commits?per_page=100" \
--jq '.[] | {sha:.sha,author:.commit.author.name,message:.commit.message,verification:.commit.verification}'
printf '%s\n' '--- PR issue comments mentioning NVSkills, signature, or DCO ---'
gh api -H 'Accept: application/vnd.github+json' \
"repos/${repo}/issues/${pr}/comments?per_page=100" \
--jq '.[] | select(.body|test("NVSkills|signature|DCO|sign-off"; "i")) | {user:.user.login,created_at,body}'
printf '%s\n' '--- PR review comments mentioning NVSkills, signature, or DCO ---'
gh api -H 'Accept: application/vnd.github+json' \
"repos/${repo}/pulls/${pr}/comments?per_page=100" \
--jq '.[] | select(.body|test("NVSkills|signature|DCO|sign-off"; "i")) | {user:.user.login,created_at,body}'Repository: NVIDIA/cuopt
Length of output: 19433
🏁 Script executed:
#!/bin/bash
set -euo pipefail
if gh api -H 'Accept: application/vnd.github+json' \
'repos/NVIDIA/nvskills-ci/actions/runs/31509646587' \
--jq '{status,conclusion,head_sha,head_branch,event,run_attempt,html_url}' 2>/tmp/nvskills-api-error; then
gh api -H 'Accept: application/vnd.github+json' \
'repos/NVIDIA/nvskills-ci/actions/runs/31509646587/jobs?per_page=100' \
--jq '.jobs[] | {name,status,conclusion,started_at,completed_at,html_url}'
else
cat /tmp/nvskills-api-error
fiRepository: NVIDIA/cuopt
Length of output: 305
Complete the required contribution checks before merge.
The PR targets main. Only the final commit has a Signed-off-by trailer. NVSkills CI is pending, and no NVSkills validation signature commit appears in the PR. Resolve the unsigned commits, retain the validation signature after the final push, and merge only after NVSkills CI passes.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/assets/README.md` at line 14, Before merging,
amend or rebase the PR commits so every commit has a Signed-off-by trailer,
preserve or add the required NVSkills validation signature commit after the
final push, and wait for NVSkills CI to pass before merging into main.
Source: Coding guidelines
| # cuOpt Server — Deploy and client (Python/curl) | ||
|
|
||
| This skill covers **starting the server** and **client examples** (curl, Python). Server has no separate C API (clients can be any language). |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
For NVIDIA cuOpt 26.10.00, does cuOpt provide a C API separate from its HTTP REST server?
💡 Result:
Yes, NVIDIA cuOpt provides a C API that is separate from its HTTP REST server [1][2][3]. NVIDIA cuOpt is designed with a multi-interface architecture that includes a native C library (libcuopt) alongside its REST-based server [2][4][3]. The C API allows developers to interface directly with the GPU-accelerated optimization engine for solving problems such as Linear Programming (LP), Quadratic Programming (QP), and Mixed-Integer Linear Programming (MILP) [1][5][6][3]. Key details regarding the C API include: - Separate Implementation: The C API functions as a native library, distinct from the cuOpt self-hosted server, which is an HTTP/JSON service [4][3]. - Capabilities: It supports defining optimization problems, configuring solver settings, and executing solves locally without requiring a network-based REST interaction [6][7][8]. - Documentation: NVIDIA provides dedicated documentation and reference materials for the C API, including usage examples and integration guides, which are separate from the server-side API documentation [1][5][6][4]. For development, users link against the provided library and use the header files (e.g., cuopt_c.h) to access the C API functionality directly within their applications [3][9].
Citations:
- 1: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-c/index.html
- 2: https://docs.nvidia.com/cuopt/user-guide/latest/index.html
- 3: https://github.com/NVIDIA/cuopt?tab=readme-ov-file
- 4: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-server/index.html
- 5: https://docs.nvidia.com/cuopt/user-guide/26.04.00/cuopt-c/quick-start.html
- 6: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-c/lp-qp-milp/lp-qp-milp-c-api.html
- 7: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-c/lp-milp/lp-milp-c-api.html
- 8: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-c/lp-qp-milp/lp-qp-milp-c-api.html.md
- 9: https://github.com/nvidia/skills/blob/HEAD/skills/cuopt-numerical-optimization-api/references/c_api.md
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- skill excerpt ---'
sed -n '1,35p' skills/cuopt-server-api-python/SKILL.md
printf '%s\n' '--- relevant repository references ---'
rg -n -i --glob '!**/.git/**' 'no separate C API|cuopt_c\.h|C API|cuOpt C' skills/cuopt-server-api-python skills/cuopt-numerical-optimization-api 2>/dev/null || trueRepository: NVIDIA/cuopt
Length of output: 8195
Correct the C API statement.
Server has no separate C API is incorrect. cuOpt provides a separate C API for direct LP, QP, and MILP use. State that the REST server accepts HTTP clients in any language, while cuOpt also provides a separate C API.
🧰 Tools
🪛 SkillSpector (2.5.1)
[warning] 54: [RP1] null: Docker image references without a specific tag (:latest is implicit) or digest (@sha256:...) can be silently replaced by a malicious image.
Remediation: Pin the image: image:tag or image@sha256:abc123
(MCP Rug Pull (RP1))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/SKILL.md` around lines 16 - 18, Update the
introductory description in the cuOpt Server skill to remove the incorrect claim
that no separate C API exists. State that the REST server accepts HTTP clients
in any language, and that cuOpt separately provides a C API for direct LP, QP,
and MILP use.
Source: Coding guidelines
| - **QP is not exposed over REST.** Use the Python or C API for quadratic objectives. | ||
| - **The server ships no authentication or TLS.** Anything that can reach the port can submit jobs. Put it behind a gateway and treat `--server`/base URLs as trusted-network endpoints only. | ||
| - Solutions are retrieved by polling; there is no push/webhook delivery. | ||
| - One request is solved at a time per server process; concurrency requires multiple replicas. |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
For NVIDIA cuOpt 26.10.00, do cuopt_server.cuopt_service --ssl-certfileand--ssl-keyfile configure TLS for the REST server?
💡 Result:
Yes, for the NVIDIA cuOpt 26.10.00 REST server, the --ssl-certfile and --ssl-keyfile command-line arguments are used to configure TLS [1][2]. These options allow you to specify the paths to your SSL certificate and private key files, respectively, to enable HTTPS for the server [1][2]. These configurations can also be set using the corresponding environment variables CUOPT_SSL_CERTFILE and CUOPT_SSL_KEYFILE [1][2]. Please note that these flags apply specifically to the REST (HTTP/JSON) interface [1][3]. If you are using the separate gRPC remote execution service (cuopt_grpc_server), it uses different flags (such as --tls, --tls-cert, and --tls-key) for its TLS configuration [4][3]. In production environments deployed via Kubernetes, TLS is often handled at the ingress layer rather than directly within the application server [5].
Citations:
- 1: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-server/server-api/server-cli.html
- 2: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-server/server-api/server-cli.html.md
- 3: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-server/index.html
- 4: https://docs.nvidia.com/cuopt/user-guide/latest/cuopt-grpc/advanced.html
- 5: https://docs.nvidia.com/cuopt/user-guide/26.04.00/cuopt-server/nim-operator/configuration.html
🏁 Script executed:
#!/bin/bash
set -eu
for f in skills/cuopt-server-api-python/SKILL.md skills/cuopt-server-api-python/evals/evals.json; do
echo "===== $f ====="
rg -n -C 5 -- '--ssl-certfile|--ssl-keyfile|no authentication|no built-in|TLS|trusted endpoint|server offers' "$f" || true
doneRepository: NVIDIA/cuopt
Length of output: 2022
Correct the TLS guidance in the skill and evaluation.
cuopt_server.cuopt_service supports REST TLS through --ssl-certfile and --ssl-keyfile, but it does not provide built-in authentication.
- Update
skills/cuopt-server-api-python/SKILL.md. - Update
skills/cuopt-server-api-python/evals/evals.json.
🧰 Tools
🪛 SkillSpector (2.5.1)
[warning] 54: [RP1] null: Docker image references without a specific tag (:latest is implicit) or digest (@sha256:...) can be silently replaced by a malicious image.
Remediation: Pin the image: image:tag or image@sha256:abc123
(MCP Rug Pull (RP1))
📍 Affects 2 files
skills/cuopt-server-api-python/SKILL.md#L118-L121(this comment)skills/cuopt-server-api-python/evals/evals.json#L77-L86
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@skills/cuopt-server-api-python/SKILL.md` around lines 118 - 121, Correct the
REST security guidance in skills/cuopt-server-api-python/SKILL.md at lines
118-121 to state that cuopt_server.cuopt_service supports TLS via --ssl-certfile
and --ssl-keyfile, while providing no built-in authentication. Update the
corresponding evaluation wording in
skills/cuopt-server-api-python/evals/evals.json at lines 77-86 to require the
same distinction; both sites need direct changes.
Source: Coding guidelines
|
/nvskills-ci |
Signed-off-by: nvskills-svc-account <svc-nvskills-signing@nvidia.com>
|
/ok to test 9a29836 |
Originally a blank-line change to trigger NVSkills CI. The run came back blocked, so this now carries the actual fix.
Tier 1 — 15 blocking Security Scan errors
All 15 were one taint rule (
TT3) repeated: the asset clients read the server base URL viaos.environ.get, which the scanner classifies as a credential/environment source flowing into arequestsnetwork sink. Three sinks (/cuopt/health,/cuopt/request,/cuopt/solution/{reqId}) × fiveclient.pyscripts = 15.Fixed by replacing the
CUOPT_SERVER_URLenv var with anargparse--serverflag, same default (http://localhost:8000).argparseis not a tainted source, so the flow clears without losing configurability.Also addressed, all previously advisory:
timeouton every request (Bandit B113 — 10 findings)reqIdagainst[A-Za-z0-9_-]{1,64}before interpolating it into the polling URL (TT2 — 4 findings)latest-cu12/latest-cu13selected by CUDA major version, matching the repo README. The previously documentedlatest-cuda12.9-py3.13was both mutable and stale —py3.13builds stopped at 26.6, so that tag no longer tracks current releases.versionkey undermetadata: the NVSkillsfrontmatter_field_placementadvisory asks for this, but the repo's ownsync-skills-versionpre-commit hook requires a root-levelversion:in everyskills/*/SKILL.mdand re-inserts one when absent, failingcheck-style. The repo hook is a hard failure and the NVSkills item is a non-blocking MEDIUM advisory, so the root-level key stays.Purpose,Prerequisites,Instructions,Examples,Limitations, andTroubleshootingsections (schema/quality advisories)The
author_formatadvisory (Name <email>) is deliberately left as-is — LOW severity, non-blocking, and it would mean publishing a contact address.Tier 3 — infrastructure, not content
AGENT_EVALwas SKIPPED, not failed, so the gate reported "canonical Tier 3 coverage is invalid". The runner could not execute any agent:SSLEOFErroragainst the k8s API), dropping bothclaude-codeandcodex--env-mode local, wherebubblewrapat/usr/bin/bwrapfailed its smoke test and thecodexCLI was not onPATHNo content change can fix this; it needs a runner-host fix on the nvskills-ci side (repair
bwrap, use--env-mode docker, or setSKILLEVALUATOR_LOCAL_SANDBOX=off).Independently, the eval set was thin at 1 case. Expanded to 8, covering LP and MILP payloads, QP being unavailable over REST, 422 debugging, Docker deployment, client hardening, and the bundled assets.
Verification
pre-commit runclean on all changed files (ruff check, ruff format, pydocstyle, verify-copyright, verify-hardcoded-version)--helpand still exit 0 against an unreachable serverlatest-cu12,latest-cu13, andlatest-cu13-ubi10confirmed present on thenvidia/cuoptregistryFollow-up (not in this PR)
skills/cuopt-install/SKILL.mdreferences the same stalelatest-cuda12.9-py3.13tag. Left alone to keep this PR scoped to one skill, since touching it would trigger that skill's own CI tiers.🤖 Generated with Claude Code