github / github/codeql

[False positive] `py/unused-local-variable` on SQLAlchemy model definition classes

Ouverte
#11,407 4 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
acknowledged false-positive not security Python
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 18 h
PR mergées (30 j)
152

Description

Hi there,

thanks a stack for bringing LGTM to CodeQL. We used your kickstart template PR https://github.com/crate/crate-python/pull/467 for making the transition happen on one of our Python repositories and wanted to report back about a potential false positive, after mitigating all other admonitions on our end before.

With kind regards,
Andreas.

**Description of the false positive**

`py/unused-local-variable` is raised on SQLAlchemy model definition classes, which are only defined, but not used.

**Code samples or links to source code**

```python
class DummyTable(Base):
__tablename__ = "t"
pk = sa.Column(sa.String, primary_key=True)
tags = sa.Column(ObjectArray)

Base.metadata.create_all()
```

- There is a corresponding PR, including the offending code, in a repro repository at https://github.com/crate-workbench/codeql-evaluations/pull/4.

**URL to the alert on GitHub code scanning (optional)**

- https://github.com/crate/crate-python/security/code-scanning/44
- https://github.com/crate-workbench/codeql-evaluations/security/code-scanning/2

**Thoughts**

I wonder if anything can be done about it, other than manually dismissing corresponding admonitions?

As far as we understand, CodeQL does not feature inline suppression comments/instructions, like what LGTM did with `lgtm[py/import-and-import-from]`, right? (https://github.com/crate/crate-python/commit/4397cc2e7)

Do you have any other suggestions on this matter?

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencer par comparer l’alerte `py/unused-local-variable` avec l’exemple de modèle SQLAlchemy dans la PR codeql-evaluations et les deux alertes de code scanning associées. La tâche sera considérée comme terminée lorsqu’il aura été déterminé si ce modèle est un faux positif et qu’une résolution prise en charge appropriée aura été documentée ou implémentée, y compris la question de la suppression inline.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python, sqlalchemy
Domaine
devtools, security
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.