Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions services/actions/permission_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ func parseRawPermissionsExplicit(rawPerms *yaml.Node) *repo_model.ActionsTokenPe
result.UnitAccessModes[unit.TypeReleases] = mode
case "projects":
result.UnitAccessModes[unit.TypeProjects] = mode
// Scopes github supports but gitea does not, see url for details
// https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax
Comment thread
TheFox0x7 marked this conversation as resolved.
case "artifact-metadata", "attestations", "checks", "deployments",
Comment thread
TheFox0x7 marked this conversation as resolved.
"id-token", "models", "discussions", "pages", "security-events", "statuses":

Comment thread
TheFox0x7 marked this conversation as resolved.
Outdated
default:
setting.PanicInDevOrTesting("Unrecognized permission scope: %s", scope)
}
Expand Down
30 changes: 30 additions & 0 deletions services/actions/permission_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,36 @@ func TestParseRawPermissions_ReadAll(t *testing.T) {
assert.Equal(t, perm.AccessModeRead, result.UnitAccessModes[unit.TypeProjects])
}

// TestParseRawPermissions_GithubScopes verifies that all scopes that github supports are accounted for
func TestParseRawPermissions_GithubScopes(t *testing.T) {
Comment thread
TheFox0x7 marked this conversation as resolved.
var rawPerms yaml.Node
// Taken and stripped down from:
// https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes
yamlContent := `
actions: read
artifact-metadata: read
attestations: read
checks: read
contents: read
deployments: read
id-token: write
issues: read
models: read
discussions: read
packages: read
pages: read
pull-requests: read
security-events: read
statuses: read`
err := yaml.Unmarshal([]byte(yamlContent), &rawPerms)
require.NoError(t, err)

result := parseRawPermissionsExplicit(&rawPerms)
require.NotNil(t, result)

// No asserts for permissions set on purpose
}

func TestParseRawPermissions_WriteAll(t *testing.T) {
var rawPerms yaml.Node
err := yaml.Unmarshal([]byte(`write-all`), &rawPerms)
Expand Down
Loading