File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 consumeHistoricalValidationCapability ,
88} from './github-identity.mjs'
99
10+ const unsupportedYamlCharacters =
11+ / [ \u0000 - \u0009 \u000b \u000c \u000e - \u001f \u007f - \u009f \u2028 \u2029 ] / u
12+
1013async function collectFiles ( root , output = [ ] ) {
1114 const entries = await readdir ( root , { withFileTypes : true } )
1215 for ( const entry of entries ) {
@@ -49,7 +52,7 @@ export function validateFinalizationHistory(historyLines) {
4952
5053function activeYamlLines ( source ) {
5154 return source
52- . split ( / \r ? \n / )
55+ . split ( / \r \n | [ \r \n ] / )
5356 . map ( ( line ) => line . replace ( / \s + $ / , '' ) )
5457 . filter ( ( line ) => line . trim ( ) && ! line . trimStart ( ) . startsWith ( '#' ) )
5558}
@@ -110,6 +113,7 @@ function conservativeYamlBlock(
110113}
111114
112115export function historicalWorkflowIsLowPrivilege ( source ) {
116+ if ( unsupportedYamlCharacters . test ( source ) ) return false
113117 const lines = activeYamlLines ( source )
114118 if (
115119 lines . some (
Original file line number Diff line number Diff line change @@ -5436,6 +5436,23 @@ test('historical workflow parsing is fail-closed without exposing reduced valida
54365436 ' runs-on: ubuntu-latest\n' ,
54375437 ' - permissions: write-all\n runs-on: ubuntu-latest\n' ,
54385438 ) ,
5439+ historicalWorkflow . replace (
5440+ ' runs-on: ubuntu-latest\n' ,
5441+ ' runs-on: ubuntu-latest\r permissions: write-all\n' ,
5442+ ) ,
5443+ historicalWorkflow . replace (
5444+ ' runs-on: ubuntu-latest\n' ,
5445+ ' runs-on: ubuntu-latest\u0085 permissions: write-all\n' ,
5446+ ) ,
5447+ historicalWorkflow . replace (
5448+ ' runs-on: ubuntu-latest\n' ,
5449+ ' runs-on: ubuntu-latest\u2028 permissions: write-all\n' ,
5450+ ) ,
5451+ historicalWorkflow . replace (
5452+ ' runs-on: ubuntu-latest\n' ,
5453+ ' runs-on: ubuntu-latest\u2029 permissions: write-all\n' ,
5454+ ) ,
5455+ historicalWorkflow . replace ( 'ubuntu-latest' , 'ubuntu-latest\u0000' ) ,
54395456 `${ historicalWorkflow }
54405457!!str permissions: write-all
54415458` ,
You can’t perform that action at this time.
0 commit comments