github / github/codeql

py/HardcodedCredentials misses common credential patterns and flags usernames.

Offen
#21,620 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
acknowledged Python
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

Some patterns are missing, for example:
```python
api_key = "sk-1234567890" # Missed: API key
db_url = "postgres://user:pass@host/db" # Missed: URL credentials
```

Second, I am not sure if the username is seen as a credential in a usual project, but this rule will flag the username.
This is beyond the definition in CWE-798 (
The product contains hard-coded credentials, such as a password or cryptographic key.)

```python
USERNAME = "admin" # Flagged
```

I also found that the rule will lose the taint in the following case:
```python
USERNAME = "road_runner"
PASSWORD = "insecure_pwd"
options = {"password": PASSWORD}

conn = client.connect(username=USERNAME, password=PASSWORD) # Flagged
log.debug("Options: %s", options) # Missing
conn = client.connect(options=options) # Still Missing
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the py/HardcodedCredentials rule and reproduce the API-key, URL-credential, username, and options examples from the issue. Read how the rule models credential patterns and propagates taint through the options dictionary. Done means the missing credential cases are detected without treating ordinary usernames as credentials, with coverage for the reported examples.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
security
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.