-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Authentication when a pre-existing invalid token is stored [HEAD…
…-1197] (#4994) --------- Co-authored-by: Avishagp <[email protected]>
- Loading branch information
1 parent
8f1ff94
commit 2890b46
Showing
5 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const ciEnvs = new Set([ | ||
export const ciEnvs = new Set([ | ||
'SNYK_CI', | ||
'CI', | ||
'CONTINUOUS_INTEGRATION', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { runSnykCLI } from '../jest/util/runSnykCLI'; | ||
|
||
export async function getCliConfig(): Promise<Record<string, string>> { | ||
let initialConfig: Record<string, string> = {}; | ||
const { stdout } = await runSnykCLI('config'); | ||
if (stdout) { | ||
initialConfig = stdout | ||
.trim() | ||
.split('\n') | ||
.reduce((acc, line) => { | ||
const [key, value] = line.split(': '); | ||
return { | ||
...acc, | ||
[key]: value, | ||
}; | ||
}, {}); | ||
} | ||
return initialConfig; | ||
} | ||
|
||
export async function restoreCliConfig(config: Record<string, string>) { | ||
await runSnykCLI('config clear'); | ||
if (Object.keys(config).length > 0) { | ||
for (const key in config) { | ||
await runSnykCLI(`config set ${key}=${config[key]}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters