Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanitize user input #187

Closed
wants to merge 7 commits into from
Closed

Sanitize user input #187

wants to merge 7 commits into from

Conversation

flenny
Copy link
Member

@flenny flenny commented May 3, 2024

This fixes some CodeQL code scanning alerts.

flenny added 2 commits May 3, 2024 10:26
A malicious user may be able to forge new log entries or may access
unexpected resources.
Comment on lines 7 to 33
public void SanitizeFileNameForValidFileNames()
{
AssertSanitizeFileName("SQUIRRELGENESIS", "SQUIRRELGENESIS");
AssertSanitizeFileName("JUNIORARK.xyz", "JUNIORARK.xyz");
AssertSanitizeFileName("PEEVEDBEAM-ANT.MESS.abc", "PEEVEDBEAM-ANT.MESS.abc");
AssertSanitizeFileName("WEIRD WATER.example", "WEIRD WATER.example");
AssertSanitizeFileName("AUTOFIRE123.doc", "AUTOFIRE123.doc");
AssertSanitizeFileName("SUNNY(1).doc", "SUNNY(1).doc");
AssertSanitizeFileName("ODD_MONKEY.doc", "ODD_MONKEY.doc");
AssertSanitizeFileName("SILLY,MONKEY.docx", "SILLY,MONKEY.docx");
AssertSanitizeFileName("CamelCase.bat", "CamelCase.bat");
AssertSanitizeFileName("SLICKER-CHIPMUNK.bat", "SLICKER-CHIPMUNK.bat");
}

[TestMethod]
public void SanitizeFileNameForInvalidFileNames()
{
AssertSanitizeFileName("CHIPMUNKWALK", " CHIPMUNKWALK ");
AssertSanitizeFileName("SLEEPYBOUNCE", "SLEEPYBOUNCE\n");
AssertSanitizeFileName("PLOWARK", "PLOWARK\r");
AssertSanitizeFileName("JUNIORGLEE", "JUNIORGLEE\t");
AssertSanitizeFileName("LATENTROUTE34", "LATENTROUTE?34");
AssertSanitizeFileName("TRAWLSOUFFLE", "TRAWLSOUFFLE*");
AssertSanitizeFileName("VIOLENTIRON", "><VIOLENTIRON\"|");
AssertSanitizeFileName("YELLOWBAGEL", "YELLOWBAGEL://");
AssertSanitizeFileName("ZANYWATER", "ZANYWATER$");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQ: Tests als DataRows umsetzten. So werden gleich alle tests ausgeführt auch wenn einer davon fehlschlägt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PP: Die gefixten Alerts mit Nr. Verlinken

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wart noch kurz mit dem Review... Bin nur CodeQL am Testen 😅

danjov
danjov previously approved these changes May 3, 2024
/// <summary>
/// GeoPilot API extensions.
/// </summary>
public static class Extensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PP: Umbenenn zu StringExtensions, da diese Klasse genau das beinhaltet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Danke! Wartet bitte noch mit dem Review... ich schliesse diesen hier wieder 😅

@flenny flenny closed this May 3, 2024
@flenny flenny deleted the sanitize-user-input branch May 3, 2024 12:55
@flenny flenny mentioned this pull request May 3, 2024
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.

3 participants