mirror of https://github.com/actions/toolkit
parent
4beda9cbc0
commit
30995490f2
File diff suppressed because it is too large
Load Diff
|
@ -24,7 +24,7 @@
|
|||
"eslint-plugin-jest": "^22.21.0",
|
||||
"flow-bin": "^0.115.0",
|
||||
"jest": "^27.2.5",
|
||||
"lerna": "^4.0.0",
|
||||
"lerna": "^5.4.0",
|
||||
"prettier": "^1.19.1",
|
||||
"ts-jest": "^27.0.5",
|
||||
"typescript": "^3.9.9"
|
||||
|
|
|
@ -132,10 +132,12 @@ describe('@actions/core', () => {
|
|||
it('exportVariable does not allow delimiter as value', () => {
|
||||
const command = 'ENV'
|
||||
createFileCommandFile(command)
|
||||
|
||||
|
||||
expect(() => {
|
||||
core.exportVariable('my var', `good stuff ${DELIMITER} bad stuff`)
|
||||
}).toThrow(`Unexpected input: value should not contain the delimiter "${DELIMITER}"`)
|
||||
}).toThrow(
|
||||
`Unexpected input: value should not contain the delimiter "${DELIMITER}"`
|
||||
)
|
||||
|
||||
const filePath = path.join(__dirname, `test/${command}`)
|
||||
fs.unlinkSync(filePath)
|
||||
|
@ -144,11 +146,13 @@ describe('@actions/core', () => {
|
|||
it('exportVariable does not allow delimiter as name', () => {
|
||||
const command = 'ENV'
|
||||
createFileCommandFile(command)
|
||||
|
||||
|
||||
expect(() => {
|
||||
core.exportVariable(`good stuff ${DELIMITER} bad stuff`, 'test')
|
||||
}).toThrow(`Unexpected input: name should not contain the delimiter "${DELIMITER}"`)
|
||||
|
||||
}).toThrow(
|
||||
`Unexpected input: name should not contain the delimiter "${DELIMITER}"`
|
||||
)
|
||||
|
||||
const filePath = path.join(__dirname, `test/${command}`)
|
||||
fs.unlinkSync(filePath)
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ import {toCommandProperties, toCommandValue} from './utils'
|
|||
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import {v4 as uuidv4} from 'uuid'
|
||||
|
||||
import {OidcClient} from './oidc-utils'
|
||||
|
||||
|
@ -89,13 +89,17 @@ export function exportVariable(name: string, val: any): void {
|
|||
if (filePath) {
|
||||
const delimiter = `ghadelimiter_${uuidv4()}`
|
||||
|
||||
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
|
||||
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
|
||||
if (name.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`)
|
||||
throw new Error(
|
||||
`Unexpected input: name should not contain the delimiter "${delimiter}"`
|
||||
)
|
||||
}
|
||||
|
||||
if (convertedVal.includes(delimiter)) {
|
||||
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`)
|
||||
throw new Error(
|
||||
`Unexpected input: value should not contain the delimiter "${delimiter}"`
|
||||
)
|
||||
}
|
||||
|
||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`
|
||||
|
|
Loading…
Reference in New Issue