@@ -4603,8 +4603,11 @@ var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
46034603// Max safe segment length for coercion.
46044604var MAX_SAFE_COMPONENT_LENGTH = 16
46054605
4606+ var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
4607+
46064608// The actual regexps go on exports.re
46074609var re = exports . re = [ ]
4610+ var safeRe = exports . safeRe = [ ]
46084611var src = exports . src = [ ]
46094612var t = exports . tokens = { }
46104613var R = 0
@@ -4613,6 +4616,31 @@ function tok (n) {
46134616 t [ n ] = R ++
46144617}
46154618
4619+ var LETTERDASHNUMBER = '[a-zA-Z0-9-]'
4620+
4621+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
4622+ // used internally via the safeRe object since all inputs in this library get
4623+ // normalized first to trim and collapse all extra whitespace. The original
4624+ // regexes are exported for userland consumption and lower level usage. A
4625+ // future breaking change could export the safer regex only with a note that
4626+ // all input should have extra whitespace removed.
4627+ var safeRegexReplacements = [
4628+ [ '\\s' , 1 ] ,
4629+ [ '\\d' , MAX_LENGTH ] ,
4630+ [ LETTERDASHNUMBER , MAX_SAFE_BUILD_LENGTH ] ,
4631+ ]
4632+
4633+ function makeSafeRe ( value ) {
4634+ for ( var i = 0 ; i < safeRegexReplacements . length ; i ++ ) {
4635+ var token = safeRegexReplacements [ i ] [ 0 ]
4636+ var max = safeRegexReplacements [ i ] [ 1 ]
4637+ value = value
4638+ . split ( token + '*' ) . join ( token + '{0,' + max + '}' )
4639+ . split ( token + '+' ) . join ( token + '{1,' + max + '}' )
4640+ }
4641+ return value
4642+ }
4643+
46164644// The following Regular Expressions can be used for tokenizing,
46174645// validating, and parsing SemVer version strings.
46184646
@@ -4622,14 +4650,14 @@ function tok (n) {
46224650tok ( 'NUMERICIDENTIFIER' )
46234651src [ t . NUMERICIDENTIFIER ] = '0|[1-9]\\d*'
46244652tok ( 'NUMERICIDENTIFIERLOOSE' )
4625- src [ t . NUMERICIDENTIFIERLOOSE ] = '[0-9] +'
4653+ src [ t . NUMERICIDENTIFIERLOOSE ] = '\\d +'
46264654
46274655// ## Non-numeric Identifier
46284656// Zero or more digits, followed by a letter or hyphen, and then zero or
46294657// more letters, digits, or hyphens.
46304658
46314659tok ( 'NONNUMERICIDENTIFIER' )
4632- src [ t . NONNUMERICIDENTIFIER ] = '\\d*[a-zA-Z-][a-zA-Z0-9-] *'
4660+ src [ t . NONNUMERICIDENTIFIER ] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + ' *'
46334661
46344662// ## Main Version
46354663// Three dot-separated numeric identifiers.
@@ -4671,7 +4699,7 @@ src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
46714699// Any combination of digits, letters, or hyphens.
46724700
46734701tok ( 'BUILDIDENTIFIER' )
4674- src [ t . BUILDIDENTIFIER ] = '[0-9A-Za-z-] +'
4702+ src [ t . BUILDIDENTIFIER ] = LETTERDASHNUMBER + ' +'
46754703
46764704// ## Build Metadata
46774705// Plus sign, followed by one or more period-separated build metadata
@@ -4751,6 +4779,7 @@ src[t.COERCE] = '(^|[^\\d])' +
47514779 '(?:$|[^\\d])'
47524780tok ( 'COERCERTL' )
47534781re [ t . COERCERTL ] = new RegExp ( src [ t . COERCE ] , 'g' )
4782+ safeRe [ t . COERCERTL ] = new RegExp ( makeSafeRe ( src [ t . COERCE ] ) , 'g' )
47544783
47554784// Tilde ranges.
47564785// Meaning is "reasonably at or greater than"
@@ -4760,6 +4789,7 @@ src[t.LONETILDE] = '(?:~>?)'
47604789tok ( 'TILDETRIM' )
47614790src [ t . TILDETRIM ] = '(\\s*)' + src [ t . LONETILDE ] + '\\s+'
47624791re [ t . TILDETRIM ] = new RegExp ( src [ t . TILDETRIM ] , 'g' )
4792+ safeRe [ t . TILDETRIM ] = new RegExp ( makeSafeRe ( src [ t . TILDETRIM ] ) , 'g' )
47634793var tildeTrimReplace = '$1~'
47644794
47654795tok ( 'TILDE' )
@@ -4775,6 +4805,7 @@ src[t.LONECARET] = '(?:\\^)'
47754805tok ( 'CARETTRIM' )
47764806src [ t . CARETTRIM ] = '(\\s*)' + src [ t . LONECARET ] + '\\s+'
47774807re [ t . CARETTRIM ] = new RegExp ( src [ t . CARETTRIM ] , 'g' )
4808+ safeRe [ t . CARETTRIM ] = new RegExp ( makeSafeRe ( src [ t . CARETTRIM ] ) , 'g' )
47784809var caretTrimReplace = '$1^'
47794810
47804811tok ( 'CARET' )
@@ -4796,6 +4827,7 @@ src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
47964827
47974828// this one has to use the /g flag
47984829re [ t . COMPARATORTRIM ] = new RegExp ( src [ t . COMPARATORTRIM ] , 'g' )
4830+ safeRe [ t . COMPARATORTRIM ] = new RegExp ( makeSafeRe ( src [ t . COMPARATORTRIM ] ) , 'g' )
47994831var comparatorTrimReplace = '$1$2$3'
48004832
48014833// Something like `1.2.3 - 1.2.4`
@@ -4824,6 +4856,14 @@ for (var i = 0; i < R; i++) {
48244856 debug ( i , src [ i ] )
48254857 if ( ! re [ i ] ) {
48264858 re [ i ] = new RegExp ( src [ i ] )
4859+
4860+ // Replace all greedy whitespace to prevent regex dos issues. These regex are
4861+ // used internally via the safeRe object since all inputs in this library get
4862+ // normalized first to trim and collapse all extra whitespace. The original
4863+ // regexes are exported for userland consumption and lower level usage. A
4864+ // future breaking change could export the safer regex only with a note that
4865+ // all input should have extra whitespace removed.
4866+ safeRe [ i ] = new RegExp ( makeSafeRe ( src [ i ] ) )
48274867 }
48284868}
48294869
@@ -4848,7 +4888,7 @@ function parse (version, options) {
48484888 return null
48494889 }
48504890
4851- var r = options . loose ? re [ t . LOOSE ] : re [ t . FULL ]
4891+ var r = options . loose ? safeRe [ t . LOOSE ] : safeRe [ t . FULL ]
48524892 if ( ! r . test ( version ) ) {
48534893 return null
48544894 }
@@ -4903,7 +4943,7 @@ function SemVer (version, options) {
49034943 this . options = options
49044944 this . loose = ! ! options . loose
49054945
4906- var m = version . trim ( ) . match ( options . loose ? re [ t . LOOSE ] : re [ t . FULL ] )
4946+ var m = version . trim ( ) . match ( options . loose ? safeRe [ t . LOOSE ] : safeRe [ t . FULL ] )
49074947
49084948 if ( ! m ) {
49094949 throw new TypeError ( 'Invalid Version: ' + version )
@@ -5348,6 +5388,7 @@ function Comparator (comp, options) {
53485388 return new Comparator ( comp , options )
53495389 }
53505390
5391+ comp = comp . trim ( ) . split ( / \s + / ) . join ( ' ' )
53515392 debug ( 'comparator' , comp , options )
53525393 this . options = options
53535394 this . loose = ! ! options . loose
@@ -5364,7 +5405,7 @@ function Comparator (comp, options) {
53645405
53655406var ANY = { }
53665407Comparator . prototype . parse = function ( comp ) {
5367- var r = this . options . loose ? re [ t . COMPARATORLOOSE ] : re [ t . COMPARATOR ]
5408+ var r = this . options . loose ? safeRe [ t . COMPARATORLOOSE ] : safeRe [ t . COMPARATOR ]
53685409 var m = comp . match ( r )
53695410
53705411 if ( ! m ) {
@@ -5488,17 +5529,24 @@ function Range (range, options) {
54885529 this . loose = ! ! options . loose
54895530 this . includePrerelease = ! ! options . includePrerelease
54905531
5491- // First, split based on boolean or ||
5532+ // First reduce all whitespace as much as possible so we do not have to rely
5533+ // on potentially slow regexes like \s*. This is then stored and used for
5534+ // future error messages as well.
54925535 this . raw = range
5493- this . set = range . split ( / \s * \| \| \s * / ) . map ( function ( range ) {
5536+ . trim ( )
5537+ . split ( / \s + / )
5538+ . join ( ' ' )
5539+
5540+ // First, split based on boolean or ||
5541+ this . set = this . raw . split ( '||' ) . map ( function ( range ) {
54945542 return this . parseRange ( range . trim ( ) )
54955543 } , this ) . filter ( function ( c ) {
54965544 // throw out any that are not relevant for whatever reason
54975545 return c . length
54985546 } )
54995547
55005548 if ( ! this . set . length ) {
5501- throw new TypeError ( 'Invalid SemVer Range: ' + range )
5549+ throw new TypeError ( 'Invalid SemVer Range: ' + this . raw )
55025550 }
55035551
55045552 this . format ( )
@@ -5517,28 +5565,27 @@ Range.prototype.toString = function () {
55175565
55185566Range . prototype . parseRange = function ( range ) {
55195567 var loose = this . options . loose
5520- range = range . trim ( )
55215568 // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
5522- var hr = loose ? re [ t . HYPHENRANGELOOSE ] : re [ t . HYPHENRANGE ]
5569+ var hr = loose ? safeRe [ t . HYPHENRANGELOOSE ] : safeRe [ t . HYPHENRANGE ]
55235570 range = range . replace ( hr , hyphenReplace )
55245571 debug ( 'hyphen replace' , range )
55255572 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
5526- range = range . replace ( re [ t . COMPARATORTRIM ] , comparatorTrimReplace )
5527- debug ( 'comparator trim' , range , re [ t . COMPARATORTRIM ] )
5573+ range = range . replace ( safeRe [ t . COMPARATORTRIM ] , comparatorTrimReplace )
5574+ debug ( 'comparator trim' , range , safeRe [ t . COMPARATORTRIM ] )
55285575
55295576 // `~ 1.2.3` => `~1.2.3`
5530- range = range . replace ( re [ t . TILDETRIM ] , tildeTrimReplace )
5577+ range = range . replace ( safeRe [ t . TILDETRIM ] , tildeTrimReplace )
55315578
55325579 // `^ 1.2.3` => `^1.2.3`
5533- range = range . replace ( re [ t . CARETTRIM ] , caretTrimReplace )
5580+ range = range . replace ( safeRe [ t . CARETTRIM ] , caretTrimReplace )
55345581
55355582 // normalize spaces
55365583 range = range . split ( / \s + / ) . join ( ' ' )
55375584
55385585 // At this point, the range is completely trimmed and
55395586 // ready to be split into comparators.
55405587
5541- var compRe = loose ? re [ t . COMPARATORLOOSE ] : re [ t . COMPARATOR ]
5588+ var compRe = loose ? safeRe [ t . COMPARATORLOOSE ] : safeRe [ t . COMPARATOR ]
55425589 var set = range . split ( ' ' ) . map ( function ( comp ) {
55435590 return parseComparator ( comp , this . options )
55445591 } , this ) . join ( ' ' ) . split ( / \s + / )
@@ -5638,7 +5685,7 @@ function replaceTildes (comp, options) {
56385685}
56395686
56405687function replaceTilde ( comp , options ) {
5641- var r = options . loose ? re [ t . TILDELOOSE ] : re [ t . TILDE ]
5688+ var r = options . loose ? safeRe [ t . TILDELOOSE ] : safeRe [ t . TILDE ]
56425689 return comp . replace ( r , function ( _ , M , m , p , pr ) {
56435690 debug ( 'tilde' , comp , _ , M , m , p , pr )
56445691 var ret
@@ -5679,7 +5726,7 @@ function replaceCarets (comp, options) {
56795726
56805727function replaceCaret ( comp , options ) {
56815728 debug ( 'caret' , comp , options )
5682- var r = options . loose ? re [ t . CARETLOOSE ] : re [ t . CARET ]
5729+ var r = options . loose ? safeRe [ t . CARETLOOSE ] : safeRe [ t . CARET ]
56835730 return comp . replace ( r , function ( _ , M , m , p , pr ) {
56845731 debug ( 'caret' , comp , _ , M , m , p , pr )
56855732 var ret
@@ -5738,7 +5785,7 @@ function replaceXRanges (comp, options) {
57385785
57395786function replaceXRange ( comp , options ) {
57405787 comp = comp . trim ( )
5741- var r = options . loose ? re [ t . XRANGELOOSE ] : re [ t . XRANGE ]
5788+ var r = options . loose ? safeRe [ t . XRANGELOOSE ] : safeRe [ t . XRANGE ]
57425789 return comp . replace ( r , function ( ret , gtlt , M , m , p , pr ) {
57435790 debug ( 'xRange' , comp , ret , gtlt , M , m , p , pr )
57445791 var xM = isX ( M )
@@ -5813,7 +5860,7 @@ function replaceXRange (comp, options) {
58135860function replaceStars ( comp , options ) {
58145861 debug ( 'replaceStars' , comp , options )
58155862 // Looseness is ignored here. star is always as loose as it gets!
5816- return comp . trim ( ) . replace ( re [ t . STAR ] , '' )
5863+ return comp . trim ( ) . replace ( safeRe [ t . STAR ] , '' )
58175864}
58185865
58195866// This function is passed to string.replace(re[t.HYPHENRANGE])
@@ -6139,7 +6186,7 @@ function coerce (version, options) {
61396186
61406187 var match = null
61416188 if ( ! options . rtl ) {
6142- match = version . match ( re [ t . COERCE ] )
6189+ match = version . match ( safeRe [ t . COERCE ] )
61436190 } else {
61446191 // Find the right-most coercible string that does not share
61456192 // a terminus with a more left-ward coercible string.
@@ -6150,17 +6197,17 @@ function coerce (version, options) {
61506197 // Stop when we get a match that ends at the string end, since no
61516198 // coercible string can be more right-ward without the same terminus.
61526199 var next
6153- while ( ( next = re [ t . COERCERTL ] . exec ( version ) ) &&
6200+ while ( ( next = safeRe [ t . COERCERTL ] . exec ( version ) ) &&
61546201 ( ! match || match . index + match [ 0 ] . length !== version . length )
61556202 ) {
61566203 if ( ! match ||
61576204 next . index + next [ 0 ] . length !== match . index + match [ 0 ] . length ) {
61586205 match = next
61596206 }
6160- re [ t . COERCERTL ] . lastIndex = next . index + next [ 1 ] . length + next [ 2 ] . length
6207+ safeRe [ t . COERCERTL ] . lastIndex = next . index + next [ 1 ] . length + next [ 2 ] . length
61616208 }
61626209 // leave it in a clean state
6163- re [ t . COERCERTL ] . lastIndex = - 1
6210+ safeRe [ t . COERCERTL ] . lastIndex = - 1
61646211 }
61656212
61666213 if ( match === null ) {
@@ -6710,28 +6757,56 @@ const io = __nccwpck_require__(7436);
67106757
67116758const urls = {
67126759 'linux' : 'https://releases.stackql.io/stackql/latest/stackql_linux_amd64.zip' ,
6713- 'darwin' : 'https://storage.googleapis.com/stackql-public-releases/latest/stackql_darwin_multiarch.pkg' ,
6760+ // 'darwin': 'https://storage.googleapis.com/stackql-public-releases/latest/stackql_darwin_multiarch.pkg',
67146761 'win32' : 'https://releases.stackql.io/stackql/latest/stackql_windows_amd64.zip' ,
67156762}
67166763
6764+ // async function downloadCLI(osPlatform){
6765+ // try {
6766+
6767+ // core.info(`downloading stackql binary for ${osPlatform}`);
6768+ // const url = urls[osPlatform]
6769+ // core.debug(`binary location: ${url}`);
6770+
6771+ // switch (osPlatform) {
6772+ // case 'win32':
6773+ // return await tc.extractZip(await tc.downloadTool(url));
6774+ // case 'darwin':
6775+ // let tmpPath = await tc.downloadTool(url);
6776+ // core.info(`extracting mac pkg in ${tmpPath}...`);
6777+ // const installPath = '/Users/runner/work/_temp/stackql-pkg';
6778+ // execSync(`pkgutil --expand-full ${tmpPath} ${installPath}`);
6779+ // return `${installPath}/Payload`;
6780+ // case 'linux':
6781+ // return await tc.extractZip(await tc.downloadTool(url));
6782+ // default:
6783+ // throw new Error(`Unsupported platform: ${osPlatform}`);
6784+ // }
6785+
6786+ // } catch (error) {
6787+ // core.error(error);
6788+ // throw error;
6789+ // }
6790+ // }
6791+
67176792async function downloadCLI ( osPlatform ) {
67186793 try {
67196794
67206795 core . info ( `downloading stackql binary for ${ osPlatform } ` ) ;
6721- const url = urls [ osPlatform ]
6722- core . debug ( `binary location: ${ url } ` ) ;
6796+ // const url = urls[osPlatform];
6797+ // core.debug(`binary location: ${url}`);
67236798
67246799 switch ( osPlatform ) {
67256800 case 'win32' :
6726- return await tc . extractZip ( await tc . downloadTool ( url ) ) ;
6801+ return await tc . extractZip ( await tc . downloadTool ( urls [ osPlatform ] ) ) ;
67276802 case 'darwin' :
6728- let tmpPath = await tc . downloadTool ( url ) ;
6729- core . info ( `extracting mac pkg in ${ tmpPath } ...` ) ;
6730- const installPath = '/Users/runner/work/_temp/ stackql-pkg' ;
6731- execSync ( `pkgutil --expand-full ${ tmpPath } ${ installPath } ` ) ;
6732- return ` ${ installPath } /Payload` ;
6803+ core . info ( `installing stackql using Homebrew` ) ;
6804+ execSync ( 'brew install stackql' , { stdio : 'inherit' } ) ;
6805+ // Assuming stackql installs to a standard location accessible in the PATH
6806+ // No need to return a path since brew handles placing it in the PATH
6807+ return '/usr/local/bin' ; // or wherever brew installs binaries
67336808 case 'linux' :
6734- return await tc . extractZip ( await tc . downloadTool ( url ) ) ;
6809+ return await tc . extractZip ( await tc . downloadTool ( urls [ osPlatform ] ) ) ;
67356810 default :
67366811 throw new Error ( `Unsupported platform: ${ osPlatform } ` ) ;
67376812 }
@@ -6742,6 +6817,7 @@ async function downloadCLI(osPlatform){
67426817 }
67436818}
67446819
6820+
67456821async function makeExecutable ( cliPath , osPlatform ) {
67466822 try {
67476823 if ( osPlatform === 'win32' ) {
0 commit comments