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`.
|
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
|
**WARNING** The add-mask command only supports single-line secrets. To register
|
||||||
secrets or multi-line secrets that have been escaped. `@actions/core`
|
a multi-line secret, the recommended practice is to register each line individually. Otherwise, it will
|
||||||
`setSecret` will escape the string you provide by default. When an escaped
|
not be masked. `@actions/core >= 1.11.0` `setSecret` will perform this automatically.
|
||||||
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** Do **not** mask short values if you can avoid it, it could render your output unreadable (and future steps' output as well).
|
**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`
|
For example, if you mask the letter `l`, running `echo "Hello FOO BAR World"` will now print `He*********o FOO BAR Wor****d`
|
||||||
|
|||||||
+1
-39
@@ -37,12 +37,9 @@ export class DownloadProgress {
|
|||||||
segmentSize: number
|
segmentSize: number
|
||||||
segmentOffset: number
|
segmentOffset: number
|
||||||
receivedBytes: number
|
receivedBytes: number
|
||||||
previouslyReceivedBytes: number
|
|
||||||
lastTimeOfNewBytes?: number
|
|
||||||
startTime: number
|
startTime: number
|
||||||
displayedComplete: boolean
|
displayedComplete: boolean
|
||||||
timeoutHandle?: ReturnType<typeof setTimeout>
|
timeoutHandle?: ReturnType<typeof setTimeout>
|
||||||
abortController?: AbortController
|
|
||||||
|
|
||||||
constructor(contentLength: number) {
|
constructor(contentLength: number) {
|
||||||
this.contentLength = contentLength
|
this.contentLength = contentLength
|
||||||
@@ -50,11 +47,8 @@ export class DownloadProgress {
|
|||||||
this.segmentSize = 0
|
this.segmentSize = 0
|
||||||
this.segmentOffset = 0
|
this.segmentOffset = 0
|
||||||
this.receivedBytes = 0
|
this.receivedBytes = 0
|
||||||
this.previouslyReceivedBytes = 0
|
|
||||||
this.lastTimeOfNewBytes = undefined
|
|
||||||
this.displayedComplete = false
|
this.displayedComplete = false
|
||||||
this.startTime = Date.now()
|
this.startTime = Date.now()
|
||||||
this.abortController = undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,7 +62,6 @@ export class DownloadProgress {
|
|||||||
this.segmentIndex = this.segmentIndex + 1
|
this.segmentIndex = this.segmentIndex + 1
|
||||||
this.segmentSize = segmentSize
|
this.segmentSize = segmentSize
|
||||||
this.receivedBytes = 0
|
this.receivedBytes = 0
|
||||||
this.previouslyReceivedBytes = 0
|
|
||||||
|
|
||||||
core.debug(
|
core.debug(
|
||||||
`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`
|
`Downloading segment at offset ${this.segmentOffset} with length ${this.segmentSize}...`
|
||||||
@@ -91,22 +84,6 @@ export class DownloadProgress {
|
|||||||
return this.segmentOffset + this.receivedBytes
|
return this.segmentOffset + this.receivedBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
setLastTimeOfNewBytes(): void {
|
|
||||||
this.lastTimeOfNewBytes = Date.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
getLastTimeOfNewBytes(): number | undefined {
|
|
||||||
return this.lastTimeOfNewBytes
|
|
||||||
}
|
|
||||||
|
|
||||||
setAbortController(abortReference: AbortController): void {
|
|
||||||
this.abortController = abortReference
|
|
||||||
}
|
|
||||||
|
|
||||||
triggerAbortController(): void {
|
|
||||||
this.abortController?.abort()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the download is complete.
|
* Returns true if the download is complete.
|
||||||
*/
|
*/
|
||||||
@@ -148,21 +125,7 @@ export class DownloadProgress {
|
|||||||
*/
|
*/
|
||||||
onProgress(): (progress: TransferProgressEvent) => void {
|
onProgress(): (progress: TransferProgressEvent) => void {
|
||||||
return (progress: TransferProgressEvent) => {
|
return (progress: TransferProgressEvent) => {
|
||||||
if (progress.loadedBytes > this.getTransferredBytes()) {
|
this.setReceivedBytes(progress.loadedBytes)
|
||||||
this.setReceivedBytes(progress.loadedBytes)
|
|
||||||
this.setLastTimeOfNewBytes()
|
|
||||||
} else {
|
|
||||||
// if download hanging for more than 2 minutes
|
|
||||||
if (
|
|
||||||
this.getLastTimeOfNewBytes() !== undefined &&
|
|
||||||
Date.now() - this.getLastTimeOfNewBytes()! > 120000
|
|
||||||
) {
|
|
||||||
this.triggerAbortController()
|
|
||||||
throw new Error(
|
|
||||||
'Aborting cache download as the download has stalled for more than 2 minutes.'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +252,6 @@ export async function downloadCacheStorageSDK(
|
|||||||
try {
|
try {
|
||||||
downloadProgress.startDisplayTimer()
|
downloadProgress.startDisplayTimer()
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
downloadProgress.setAbortController(controller)
|
|
||||||
const abortSignal = controller.signal
|
const abortSignal = controller.signal
|
||||||
while (!downloadProgress.isDone()) {
|
while (!downloadProgress.isDone()) {
|
||||||
const segmentStart =
|
const segmentStart =
|
||||||
|
|||||||
@@ -161,10 +161,15 @@ describe('@actions/core', () => {
|
|||||||
|
|
||||||
it('setSecret produces the correct command', () => {
|
it('setSecret produces the correct command', () => {
|
||||||
core.setSecret('secret val')
|
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([
|
assertWriteCalls([
|
||||||
`::add-mask::secret val${os.EOL}`,
|
`::add-mask::first${os.EOL}`,
|
||||||
`::add-mask::multi%0Aline%0D%0Asecret${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
|
* @param secret value of the secret
|
||||||
*/
|
*/
|
||||||
export function setSecret(secret: string): void {
|
export function setSecret(secret: string): void {
|
||||||
issueCommand('add-mask', {}, secret)
|
for (const part of secret.split(/[\r\n]+/)) {
|
||||||
|
if (part) {
|
||||||
|
issueCommand('add-mask', {}, part)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user