Skip to content

Commit

Permalink
feat(cli): remove .github dirs when initializing with a remote templa…
Browse files Browse the repository at this point in the history
…te (#8036)
  • Loading branch information
RostiMelk authored Dec 13, 2024
1 parent 85de530 commit 2222e9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/@sanity/cli/src/util/remoteTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import {x} from 'tar'

import {type CliApiClient, type PackageJson} from '../types'

const DISALLOWED_PATHS = [
// Prevent security risks from unknown GitHub Actions
'/.github/',
]

const ENV_VAR = {
...REQUIRED_ENV_VAR,
READ_TOKEN: 'SANITY_API_READ_TOKEN',
Expand Down Expand Up @@ -181,6 +186,9 @@ export async function downloadAndExtractRepo(
const pathSegments = posixPath.split(posix.sep)
rootPath = pathSegments.length ? pathSegments[0] : null
}
for (const disallowedPath of DISALLOWED_PATHS) {
if (posixPath.includes(disallowedPath)) return false
}
return posixPath.startsWith(`${rootPath}${filePath ? `/${filePath}/` : '/'}`)
},
}),
Expand Down

0 comments on commit 2222e9e

Please sign in to comment.