Skip to content

Commit

Permalink
Fix code scanning alert no. 36: Incomplete multi-character sanitization
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
Jonhvmp and github-advanced-security[bot] authored Dec 13, 2024
1 parent 80a43b5 commit f104467
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/src/models/Snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ SnippetSchema.pre<ISnippet>('save', function (next) {

// Remover atributos perigosos
let previousCode;
const dangerousAttrRegex = /on\w+=(["'])(?:(?=(\\?))\2.)*?\1/g;
do {
previousCode = this.code;
this.code = this.code.replace(/on\w+="[^"]*"/g, '').replace(/on\w+='[^']*'/g, '');
this.code = this.code.replace(dangerousAttrRegex, '');

Check failure

Code scanning / CodeQL

Incomplete multi-character sanitization High

This string may still contain
on
, which may cause an HTML attribute injection vulnerability.
} while (this.code !== previousCode);

// Remover URLs perigosas em estilos inline
Expand Down

0 comments on commit f104467

Please sign in to comment.