-
Notifications
You must be signed in to change notification settings - Fork 376
Adds ref and SHA as inputs, and sarif-id as output #889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e9aa2c6
980fd4e
0dd4dbf
5916f98
1eaaf07
1bfa9ac
260b4d5
3cc8799
63d0c78
dfe2bc4
9f36b75
72f9a88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,10 +83,10 @@ export const getCommitOid = async function (ref = "HEAD"): Promise<string> { | |
return commitOid.trim(); | ||
} catch (e) { | ||
core.info( | ||
`Failed to call git to get current commit. Continuing with data from environment: ${e}` | ||
`Failed to call git to get current commit. Continuing with data from environment or input: ${e}` | ||
); | ||
core.info((e as Error).stack || "NO STACK"); | ||
return getRequiredEnvParam("GITHUB_SHA"); | ||
return getOptionalInput("sha") || getRequiredEnvParam("GITHUB_SHA"); | ||
} | ||
}; | ||
|
||
|
@@ -431,8 +431,15 @@ export function computeAutomationID( | |
export async function getRef(): Promise<string> { | ||
// Will be in the form "refs/heads/master" on a push event | ||
// or in the form "refs/pull/N/merge" on a pull_request event | ||
const ref = getRequiredEnvParam("GITHUB_REF"); | ||
const sha = getRequiredEnvParam("GITHUB_SHA"); | ||
const refInput = getOptionalInput("ref"); | ||
const ref = refInput || getRequiredEnvParam("GITHUB_REF"); | ||
const sha = getOptionalInput("sha") || getRequiredEnvParam("GITHUB_SHA"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should probably be an error if only one of these inputs are specified. Also, I'm not sure what would happen if you specify a SHA that is not part of the current branch. Hopefully, code scanning would error out.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For 2., I would prefer option b. This way, we don't have to rely on the underlying scanner. What's your preferred solution? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EDIT: Option 1 would not be possible, because I realized integration tests can only be positive with the current setup. So, I can either leave it as-is, without a test, or use option b. |
||
|
||
// If the ref is a user-provided input, we have to skip logic | ||
// and assume that it is really where they want to upload the results. | ||
if (refInput) { | ||
return refInput; | ||
} | ||
|
||
// For pull request refs we want to detect whether the workflow | ||
// has run `git checkout HEAD^2` to analyze the 'head' ref rather | ||
|
@@ -520,7 +527,7 @@ export async function createStatusReportBase( | |
cause?: string, | ||
exception?: string | ||
): Promise<StatusReportBase> { | ||
const commitOid = process.env["GITHUB_SHA"] || ""; | ||
const commitOid = getOptionalInput("sha") || process.env["GITHUB_SHA"] || ""; | ||
const ref = await getRef(); | ||
const workflowRunIDStr = process.env["GITHUB_RUN_ID"]; | ||
let workflowRunID = -1; | ||
|
Uh oh!
There was an error while loading. Please reload this page.