File tree Expand file tree Collapse file tree
internal-packages/observability-map/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,7 +123,12 @@ export const SENSITIVE_SEGMENTS = [
123123 * layout (`resources.impersonation_.view-as.ts`) and changes nothing about what the route does.
124124 */
125125function normalizeSegment ( segment : string ) : string {
126- return segment . replace ( / _ + $ / , "" ) ;
126+ // Trimmed by hand rather than with /_+$/, which backtracks polynomially on a run of underscores
127+ // and trips CodeQL. Nothing here is attacker-controlled (the input is a filename read off disk),
128+ // so this is about not spending a reviewer's attention on the alert.
129+ let end = segment . length ;
130+ while ( end > 0 && segment [ end - 1 ] === "_" ) end -- ;
131+ return segment . slice ( 0 , end ) ;
127132}
128133
129134export type Sensitivity = { sensitive : boolean ; reasons : string [ ] } ;
You can’t perform that action at this time.
0 commit comments