@@ -9,26 +9,6 @@ import * as os from 'os'
99import * as path from 'path'
1010import axios , { isAxiosError } from 'axios'
1111
12- function validateVersion ( version : string ) : string {
13- if ( ! version ) {
14- throw new Error ( 'Version cannot be empty' )
15- }
16-
17- // Allow only numbers and dots for mise versions (e.g., 2024.12.7, 2.8.0)
18- if ( ! / ^ [ 0 - 9 . ] + $ / . test ( version ) ) {
19- throw new Error (
20- `Invalid version format: ${ version } . Only numbers and dots are allowed.`
21- )
22- }
23-
24- // Additional length check to prevent excessive input
25- if ( version . length > 20 ) {
26- throw new Error ( 'Version string too long' )
27- }
28-
29- return version . replace ( / ^ v / , '' ) // Remove 'v' prefix if present
30- }
31-
3212async function validateSubscription ( ) : Promise < void > {
3313 const API_URL = `https://agent.api.stepsecurity.io/v1/github/${ process . env . GITHUB_REPOSITORY } /actions/subscription`
3414
@@ -60,7 +40,8 @@ async function run(): Promise<void> {
6040 }
6141
6242 const version = core . getInput ( 'version' )
63- await setupMise ( version )
43+ const fetchFromGitHub = core . getBooleanInput ( 'fetch_from_github' )
44+ await setupMise ( version , fetchFromGitHub )
6445 await setEnvVars ( )
6546 if ( core . getBooleanInput ( 'reshim' ) ) {
6647 await miseReshim ( )
@@ -178,7 +159,10 @@ async function restoreMiseCache(): Promise<string | undefined> {
178159 core . info ( `mise cache restored from key: ${ cacheKey } ` )
179160}
180161
181- async function setupMise ( version : string ) : Promise < void > {
162+ async function setupMise (
163+ version : string ,
164+ fetchFromGitHub = false
165+ ) : Promise < void > {
182166 const miseBinDir = path . join ( miseDir ( ) , 'bin' )
183167 const miseBinPath = path . join (
184168 miseBinDir ,
@@ -195,12 +179,15 @@ async function setupMise(version: string): Promise<void> {
195179 : ( await zstdInstalled ( ) )
196180 ? '.tar.zst'
197181 : '.tar.gz'
198-
199- // Validate version input to prevent injection attacks
200- const rawVersion = version || ( await latestMiseVersion ( ) )
201- const validatedVersion = validateVersion ( rawVersion )
202-
203- const url = `https://github.com/jdx/mise/releases/download/v${ validatedVersion } /mise-v${ validatedVersion } -${ await getTarget ( ) } ${ ext } `
182+ let resolvedVersion = version || ( await latestMiseVersion ( ) )
183+ resolvedVersion = resolvedVersion . replace ( / ^ v / , '' )
184+ let url : string
185+ if ( ! fetchFromGitHub && ! version ) {
186+ // Only for latest version
187+ url = `https://mise.jdx.dev/mise-latest-${ await getTarget ( ) } ${ ext } `
188+ } else {
189+ url = `https://github.com/jdx/mise/releases/download/v${ resolvedVersion } /mise-v${ resolvedVersion } -${ await getTarget ( ) } ${ ext } `
190+ }
204191 const archivePath = path . join ( os . tmpdir ( ) , `mise${ ext } ` )
205192 switch ( ext ) {
206193 case '.zip' :
@@ -277,7 +264,7 @@ const testMise = async (): Promise<number> => mise(['--version'])
277264const miseInstall = async ( ) : Promise < number > =>
278265 mise ( [ `install ${ core . getInput ( 'install_args' ) } ` ] )
279266const miseLs = async ( ) : Promise < number > => mise ( [ `ls` ] )
280- const miseReshim = async ( ) : Promise < number > => mise ( [ `reshim` , `--all ` ] )
267+ const miseReshim = async ( ) : Promise < number > => mise ( [ `reshim` , `-f ` ] )
281268const mise = async ( args : string [ ] ) : Promise < number > =>
282269 core . group ( `Running mise ${ args . join ( ' ' ) } ` , async ( ) => {
283270 const cwd =
0 commit comments