[Bug]: Overly permissive regular expression range
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
Direzione di ricerca
La issue fa riferimento a tests/integration/stackscripts/test_stackscripts.py alla riga 95; esamina l'espressione regolare presente e la relativa copertura esistente. Verifica che gli intervalli di caratteri accettino solo i caratteri previsti, aggiorna il test o l'espressione pertinente ed esegui il test di integrazione associato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
CLI Version
v5.56.2
Command
It's easy to write a regular expression range that matches a wider range of characters than you intended. /[a-zA-z]/ matches all lowercase and all uppercase letters, as you would expect, but it also matches the characters: `[ \ ] ^ _ ``.
Another common problem is failing to escape the dash character in a regular expression. An unescaped dash is interpreted as part of a range. For example, in the character class [a-zA-Z0-9%=.,-_] the last character range matches the 55 characters between , and _ (both included), which overlaps with the range [0-9] and is clearly not intended by the writer.
Output
No response
Expected Behavior
[CWE-20
Actual Behavior
Improper Neutralization of Special Elements used in a Command in Shell-quote
Exploiting CVE-2021-42740
no-obscure-range
The regex [,-.]
CWE-20.
Steps to Reproduce
POC
The following code is intended to check whether a string is a valid 6 digit hex color.
import re
def is_valid_hex_color(color):
return re.match(r'^#[0-9a-fA-f]{6}$', color) is not None
However, the A-f range is overly large and matches every uppercase character. It would parse a "color" like #XXYYZZ as valid.
The fix is to use an uppercase A-F range instead.
import re
def is_valid_hex_color(color):
return re.match(r'^#[0-9a-fA-F]{6}$', color) is not None
Recommendation
Avoid any confusion about which characters are included in the range by writing unambiguous regular expressions. Always check that character ranges match only the expected characters.
- Lingua principale
- Python
- Stelle
- 442
- Fork
- 159
- Merge medio
- 7g 21h
- PR unite (30g)
- 8
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di linode/linode-cli
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linode/linode-cli#894 ·
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
linode/linode-cli#859 · 1 commento ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
linode/linode-cli#868 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
linode/linode-cli#825 · 1 commento ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
linode/linode-cli#788 ·
Tutte le issue di linode/linode-cli
Issue simili
-
agent-ready documentation needs-triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
instance instance add
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
searxng/searx-instances#939 · 1 commento ·
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100