codeant-ai-for-open-source[bot] commented on code in PR #41535:
URL: https://github.com/apache/superset/pull/41535#discussion_r3493422715


##########
scripts/scan_and_file_issues.py:
##########
@@ -0,0 +1,656 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Audit Superset's real dependency lockfiles and file a GitHub issue per 
finding.
+
+This script runs ``pip-audit`` against the repository's *real* pinned
+requirements lockfiles (``requirements/*.txt``), parses the JSON report, and
+files one idempotent GitHub issue per actionable vulnerability so that a
+downstream remediation orchestrator can pick them up.
+
+Nothing here is synthetic: the manifests audited are the ones already committed
+to the repository, and the findings come straight from the Python advisory
+databases via ``pip-audit`` and OSV.
+
+Triage rules
+------------
+* A finding is *actionable* when ``pip-audit`` reports at least one concrete
+  ``fix_versions`` entry. Actionable findings are filed under the
+  ``devin-remediate`` label -- the queue the orchestrator consumes.
+* Findings with no available fix are filed under ``no-fix-available`` (so they
+  remain visible) but are kept out of the remediation queue.
+* Severity is enriched from the OSV API and used both to drop low-severity
+  noise (``SCAN_MIN_SEVERITY``) and to sort the most severe, clearly-fixable
+  findings first before applying the volume cap (``SCAN_MAX_ISSUES``).
+
+Environment variables
+----------------------
+``GITHUB_TOKEN`` (required)
+    Token used to authenticate against the GitHub REST API.
+``GITHUB_REPOSITORY`` (required)
+    Target repository in ``owner/name`` form (provided automatically by GitHub
+    Actions).
+``SCAN_MANIFESTS`` (default ``requirements/base.txt``)
+    Comma-separated list of requirements lockfiles to audit, relative to the
+    repository root.
+``SCAN_MAX_ISSUES`` (default ``25``)
+    Maximum number of *actionable* issues to file per run. Sorting puts the
+    most severe findings first, so the cap drops the least severe overflow.
+``SCAN_MIN_SEVERITY`` (default ``LOW``)
+    Minimum severity to consider. One of ``LOW``, ``MODERATE``/``MEDIUM``,
+    ``HIGH``, ``CRITICAL``.
+``SCAN_INCLUDE_NO_FIX`` (default ``true``)
+    When truthy, also file ``no-fix-available`` issues for findings without a
+    fix. Set to ``false`` to ignore them entirely.
+``SCAN_DRY_RUN`` (default ``false``)
+    When truthy, do everything except creating labels/issues (prints what would
+    be filed). Useful for local testing without a write token.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+import os
+import re
+import subprocess
+import sys
+import tempfile
+from dataclasses import dataclass, field
+from pathlib import Path
+from typing import Any, Final
+
+import requests
+
+logger = logging.getLogger("scan_and_file_issues")

Review Comment:
   **Suggestion:** Add an explicit type hint to `logger` (for example a 
`logging.Logger` annotation) to comply with the type-hint requirement for 
relevant variables. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   The module-level `logger` variable is directly annotatable as 
`logging.Logger`, but the code assigns it without any type hint. This matches 
the rule requiring type hints on relevant variables in new or modified Python 
code.
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=51beb942cc1247bea020a8ae935037bc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=51beb942cc1247bea020a8ae935037bc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** scripts/scan_and_file_issues.py
   **Line:** 78:78
   **Comment:**
        *Custom Rule: Add an explicit type hint to `logger` (for example a 
`logging.Logger` annotation) to comply with the type-hint requirement for 
relevant variables.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41535&comment_hash=46173fd21ae8b212e9a1b53bc24a806850b3ae3881d2ace5868bf97e24573e5e&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41535&comment_hash=46173fd21ae8b212e9a1b53bc24a806850b3ae3881d2ace5868bf97e24573e5e&reaction=dislike'>👎</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to