Sitelet https://github.com/msgwing/ZeroSMTP/pull/314
Skip to content

fix(test): compare the whole line, so the link that routes reporters is actually covered - #314

Merged
msgwing merged 1 commit into
mainfrom
test-dokladny
Aug 27, 2026
Merged

msgwing merged 1 commit into
mainfrom
test-dokladny

Conversation

@msgwing

@msgwing msgwing commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Alert 15, waga wysoka: js/incomplete-url-substring-sanitization.

Jako znalezisko bezpieczeństwa — fałszywy alarm

Sprawdzany ciąg to nasz własny tekst wyjściowy, nie dane od atakującego.
Nie ma tu żadnej sanityzacji do obejścia. CodeQL widzi kształt
X.includes('https://...') i nie odróżnia go od sprawdzania adresu.

Ale wskazał realną słabość testu

Asercja szukała https://github.com/msgwing/ZeroSMTP/issues/new, a kod wypisuje
ten adres plus ?template=error-string.yml.

Usuń parametr — fragment nadal tam jest, więc stary test przechodził na
zepsutym kodzie
. A ten parametr kieruje zgłaszającego do strukturalnego
formularza zamiast do pustego zgłoszenia.

Poprawka

Porównanie całych przyciętych linii na dokładną równość. Mocniejsze niż
szukanie fragmentu i bez kształtu, który myli skaner.

Sprawdzone przez celowe zepsucie

parametr usuniety celowo:   pass 24  fail 1
po przywroceniu:            pass 25  fail 0

Dokładnie jeden test się wywala. Bramka, której nie widziałem jak się wywala,
nie byłaby sprawdzona
— to ten sam warunek, którego wymagałem od kontrybutora
przy #300, więc stosuję go do siebie.

…is actually covered

Code scanning flagged this assertion as incomplete URL substring
sanitization, high severity. As a security finding it is a false
positive - the string being tested is our own output, not attacker
input.

The alert was worth acting on anyway, because it pointed at a test that
was weaker than it looked. The assertion checked for
'https://github.com/msgwing/ZeroSMTP/issues/new' while the code emits
that URL plus '?template=error-string.yml'. Remove the parameter and the
substring is still present, so the old test passed on broken output.

That parameter is what routes a reporter to the structured error-string
form rather than a blank issue.

Now it compares whole trimmed lines for exact equality, which is
stronger and no longer has the shape the scanner reads as a URL check.

Verified by breaking it on purpose: deleting the parameter fails exactly
one test, restoring it returns 25 passing.
@msgwing
msgwing merged commit 4341d70 into main Aug 27, 2026
33 checks passed
@msgwing
msgwing deleted the test-dokladny branch August 27, 2026 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant