Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c44e73f0a5 | |||
| 0e36a96ee5 | |||
| 38e6785d19 | |||
| 9fccf58073 | |||
| 63ffaaf25e | |||
| 5ccbd5f448 |
+3
-12
@@ -50,18 +50,9 @@ function setSecret(secret: string): void {}
|
||||
|
||||
Now, future logs containing BAR will be masked. E.g. running `echo "Hello FOO BAR World"` will now print `Hello FOO **** World`.
|
||||
|
||||
**WARNING** The add-mask and setSecret commands only support single-line
|
||||
secrets or multi-line secrets that have been escaped. `@actions/core`
|
||||
`setSecret` will escape the string you provide by default. When an escaped
|
||||
multi-line string is provided the whole string and each of its lines
|
||||
individually will be masked. For example you can mask `first\nsecond\r\nthird`
|
||||
using:
|
||||
|
||||
```sh
|
||||
echo "::add-mask::first%0Asecond%0D%0Athird"
|
||||
```
|
||||
|
||||
This will mask `first%0Asecond%0D%0Athird`, `first`, `second` and `third`.
|
||||
**WARNING** The add-mask command only supports single-line secrets. To register
|
||||
a multi-line secret, the recommended practice is to register each line individually. Otherwise, it will
|
||||
not be masked. `@actions/core >= 1.11.0` `setSecret` will perform this automatically.
|
||||
|
||||
**WARNING** Do **not** mask short values if you can avoid it, it could render your output unreadable (and future steps' output as well).
|
||||
For example, if you mask the letter `l`, running `echo "Hello FOO BAR World"` will now print `He*********o FOO BAR Wor****d`
|
||||
|
||||
@@ -161,10 +161,15 @@ describe('@actions/core', () => {
|
||||
|
||||
it('setSecret produces the correct command', () => {
|
||||
core.setSecret('secret val')
|
||||
core.setSecret('multi\nline\r\nsecret')
|
||||
assertWriteCalls([`::add-mask::secret val${os.EOL}`])
|
||||
})
|
||||
|
||||
it('setSecret splits multi line secrets into multiple commands', () => {
|
||||
core.setSecret('first\nsecond\r\nthird')
|
||||
assertWriteCalls([
|
||||
`::add-mask::secret val${os.EOL}`,
|
||||
`::add-mask::multi%0Aline%0D%0Asecret${os.EOL}`
|
||||
`::add-mask::first${os.EOL}`,
|
||||
`::add-mask::second${os.EOL}`,
|
||||
`::add-mask::third${os.EOL}`
|
||||
])
|
||||
})
|
||||
|
||||
|
||||
@@ -97,7 +97,11 @@ export function exportVariable(name: string, val: any): void {
|
||||
* @param secret value of the secret
|
||||
*/
|
||||
export function setSecret(secret: string): void {
|
||||
issueCommand('add-mask', {}, secret)
|
||||
for (const part of secret.split(/[\r\n]+/)) {
|
||||
if (part) {
|
||||
issueCommand('add-mask', {}, part)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,12 +91,6 @@ describe('proxy', () => {
|
||||
expect(proxyUrl).toBeDefined()
|
||||
})
|
||||
|
||||
it('getProxyUrl returns proxyUrl if http_proxy has no protocol', () => {
|
||||
process.env['http_proxy'] = 'myproxysvr'
|
||||
const proxyUrl = pm.getProxyUrl(new URL('http://github.com'))
|
||||
expect(proxyUrl?.toString()).toBe('http://myproxysvr/')
|
||||
})
|
||||
|
||||
it('checkBypass returns true if host as no_proxy list', () => {
|
||||
process.env['no_proxy'] = 'myserver'
|
||||
const bypass = pm.checkBypass(new URL('https://myserver'))
|
||||
|
||||
@@ -14,12 +14,7 @@ export function getProxyUrl(reqUrl: URL): URL | undefined {
|
||||
})()
|
||||
|
||||
if (proxyVar) {
|
||||
try {
|
||||
return new URL(proxyVar)
|
||||
} catch {
|
||||
if (!proxyVar.startsWith('http://') && !proxyVar.startsWith('https://'))
|
||||
return new URL(`http://${proxyVar}`)
|
||||
}
|
||||
return new URL(proxyVar)
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user