Skip to content
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

Fix actions/*-artifact false positives for GHES #510

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion rule_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ var BrandingIcons = map[string]struct{}{
"zoom-out": {},
}

// These actions are still supported in GitHub Enterprise Server as the v4 back-end infrastructure
// that the *-artifact actions use is not available, or they depend on those v4 actions.
var outdatedPopularActionSpecsStillSupportedByGitHubEnterpriseServer = map[string]struct{}{
"actions/deploy-pages@v2": {},
"actions/download-artifact@v3": {},
"actions/upload-artifact@v3": {},
"actions/upload-pages-artifact@v3": {},
}

// https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsimage
func isImageOnDockerRegistry(image string) bool {
return strings.HasPrefix(image, "docker://") ||
Expand Down Expand Up @@ -374,7 +383,12 @@ func (rule *RuleAction) checkRepoAction(spec string, exec *ExecAction) {
meta, ok := PopularActions[spec]
if !ok {
if _, ok := OutdatedPopularActionSpecs[spec]; ok {
rule.Errorf(exec.Uses.Pos, "the runner of %q action is too old to run on GitHub Actions. update the action's version to fix this issue", spec)
serverURL := os.Getenv("GITHUB_SERVER_URL")
isGHES := serverURL != "https://github.com" && !strings.HasSuffix(serverURL, ".ghe.com")
_, stillSupported := outdatedPopularActionSpecsStillSupportedByGitHubEnterpriseServer[spec]
if !isGHES || !stillSupported {
rule.Errorf(exec.Uses.Pos, "the runner of %q action is too old to run on GitHub Actions. update the action's version to fix this issue", spec)
}
return
}
rule.Debug("This action is not found in popular actions data set: %s", spec)
Expand Down
Loading