Documentation
¶
Index ¶
- Variables
- func Loader(config *config.Config) (payload any, err error)
- type ClientMock
- type Dependency
- type DependencyManifestsPage
- type GitHubRepositoryMetadata
- func (r *GitHubRepositoryMetadata) DefaultBranchRequiresPRReviews() *bool
- func (r *GitHubRepositoryMetadata) IsActive() bool
- func (r *GitHubRepositoryMetadata) IsDefaultBranchProtected() *bool
- func (r *GitHubRepositoryMetadata) IsDefaultBranchProtectedFromDeletion() *bool
- func (r *GitHubRepositoryMetadata) IsMFARequiredForAdministrativeActions() *bool
- func (r *GitHubRepositoryMetadata) IsPublic() bool
- func (r *GitHubRepositoryMetadata) OrganizationBlogURL() *string
- type GraphqlRepoData
- type GraphqlRepoTree
- type HttpClient
- type ManifestNode
- type Payload
- type ReleaseAsset
- type ReleaseData
- type RepoContent
- type RepoSecurityPosture
- type RepositoryMetadata
- type RestData
- func (r *RestData) GetDirectoryContent(path string) (dirContent []*github.RepositoryContent, err error)
- func (r *RestData) GetFileContent(path string) (content *github.RepositoryContent, err error)
- func (r *RestData) GetRulesets(branchName string) []Ruleset
- func (r *RestData) HasSupportMarkdown() bool
- func (r *RestData) IsCodeRepo() (bool, error)
- func (r *RestData) MakeApiCall(endpoint string, isGithub bool) (body []byte, err error)
- func (r *RestData) Setup() error
- type Ruleset
- type SecurityPosture
- type WorkflowPermissions
Constants ¶
This section is empty.
Variables ¶
View Source
var APIBase = "https://api.github.com"
Functions ¶
Types ¶
type ClientMock ¶
type Dependency ¶
type DependencyManifestsPage ¶
type DependencyManifestsPage struct {
Repository struct {
DependencyGraphManifests struct {
TotalCount int
}
} `graphql:"repository(owner: $owner, name: $name)"`
}
type GitHubRepositoryMetadata ¶
type GitHubRepositoryMetadata struct {
Releases []ReleaseData
// contains filtered or unexported fields
}
func (*GitHubRepositoryMetadata) DefaultBranchRequiresPRReviews ¶ added in v0.19.0
func (r *GitHubRepositoryMetadata) DefaultBranchRequiresPRReviews() *bool
func (*GitHubRepositoryMetadata) IsActive ¶
func (r *GitHubRepositoryMetadata) IsActive() bool
func (*GitHubRepositoryMetadata) IsDefaultBranchProtected ¶ added in v0.19.0
func (r *GitHubRepositoryMetadata) IsDefaultBranchProtected() *bool
func (*GitHubRepositoryMetadata) IsDefaultBranchProtectedFromDeletion ¶ added in v0.19.0
func (r *GitHubRepositoryMetadata) IsDefaultBranchProtectedFromDeletion() *bool
func (*GitHubRepositoryMetadata) IsMFARequiredForAdministrativeActions ¶
func (r *GitHubRepositoryMetadata) IsMFARequiredForAdministrativeActions() *bool
func (*GitHubRepositoryMetadata) IsPublic ¶
func (r *GitHubRepositoryMetadata) IsPublic() bool
func (*GitHubRepositoryMetadata) OrganizationBlogURL ¶
func (r *GitHubRepositoryMetadata) OrganizationBlogURL() *string
type GraphqlRepoData ¶
type GraphqlRepoData struct {
Repository struct {
Name string
HasDiscussionsEnabled bool
HasIssuesEnabled bool
IsSecurityPolicyEnabled bool
Object struct {
Tree struct {
Entries []struct {
Name string
Type string // "blob" for files, "tree" for directories
Path string
}
} `graphql:"... on Tree"`
} `graphql:"object(expression: \"HEAD:\")"`
DefaultBranchRef struct {
Name string
RefUpdateRule struct {
AllowsDeletions bool
AllowsForcePushes bool
RequiredApprovingReviewCount int
}
BranchProtectionRule struct {
RestrictsPushes bool // This didn't give an accurate result
RequiresApprovingReviews bool // This gave an accurate result
RequiresCommitSignatures bool
RequiresStatusChecks bool
RequireLastPushApproval bool
RequiredStatusCheckContexts []string
}
Target struct {
OID string `graphql:"oid"` // Latest commit SHA
Commit struct {
Status struct {
State string // Overall commit status
Contexts []struct {
Context string
Description string
State string
TargetURL string `graphql:"targetUrl"`
}
} `graphql:"status"` // Classic status API
AssociatedPullRequests struct {
Nodes []struct {
StatusCheckRollup struct {
Commit struct {
CheckSuites struct {
Nodes []struct {
CheckRuns struct {
Nodes []struct {
Name string `graphql:"name"`
}
} `graphql:"checkRuns(first: 25)"`
}
} `graphql:"checkSuites(first: 25)"`
}
}
}
} `graphql:"associatedPullRequests(last: 1)"`
} `graphql:"... on Commit"`
} `graphql:"target"`
}
LicenseInfo struct {
Name string
SpdxId string
Url string
}
LatestRelease struct {
Description string
}
ContributingGuidelines struct {
Body string
}
Releases struct {
Nodes []struct {
TagName string
Name string
Assets struct {
Nodes []struct {
Name string
ContentType string
}
} `graphql:"releaseAssets(first: 100)"`
}
} `graphql:"releases(first: 1, orderBy: {field: CREATED_AT, direction: DESC})"`
} `graphql:"repository(owner: $owner, name: $name)"`
}
GraphqlRepoData is used in a query to get general repository information
type GraphqlRepoTree ¶
type GraphqlRepoTree struct {
Repository struct {
Object struct {
Tree struct {
Entries []struct {
Name string
Type string
Path string
Object *struct {
Blob struct {
IsBinary *bool
IsTruncated bool
} `graphql:"... on Blob"`
Tree struct {
Entries []struct {
Name string
Type string
Path string
Object *struct {
Blob struct {
IsBinary *bool
IsTruncated bool
} `graphql:"... on Blob"`
Tree struct {
Entries []struct {
Name string
Type string
Path string
Object *struct {
Blob struct {
IsBinary *bool
IsTruncated bool
} `graphql:"... on Blob"`
} `graphql:"object"`
}
} `graphql:"... on Tree"`
} `graphql:"object"`
}
} `graphql:"... on Tree"`
} `graphql:"object"`
}
} `graphql:"... on Tree"`
} `graphql:"object(expression: $branch)"`
} `graphql:"repository(owner: $owner, name: $name)"`
}
type ManifestNode ¶
type ManifestNode struct {
Filename string
Dependencies []Dependency
}
type Payload ¶
type Payload struct {
*GraphqlRepoData
*RestData
Config *config.Config
SuspectedBinaries []string
RepositoryMetadata RepositoryMetadata
DependencyManifestsCount int
IsCodeRepo bool
SecurityPosture SecurityPosture
// contains filtered or unexported fields
}
func NewPayloadWithHTTPMock ¶
func (*Payload) GetSuspectedBinaries ¶
type ReleaseAsset ¶
type ReleaseData ¶
type ReleaseData struct {
Id int `json:"id"`
Name string `json:"name"`
TagName string `json:"tag_name"`
URL string `json:"url"`
Assets []ReleaseAsset `json:"assets"`
}
type RepoContent ¶
type RepoContent struct {
Content []*github.RepositoryContent
SubContent map[string]RepoContent
}
func (*RepoContent) GetSubdirContentByPath ¶
func (c *RepoContent) GetSubdirContentByPath(r *RestData, path string) (RepoContent, error)
type RepoSecurityPosture ¶
type RepoSecurityPosture struct {
// contains filtered or unexported fields
}
func (*RepoSecurityPosture) DefinesPolicyForHandlingSecrets ¶
func (rsp *RepoSecurityPosture) DefinesPolicyForHandlingSecrets() bool
func (*RepoSecurityPosture) PreventsPushingSecrets ¶
func (rsp *RepoSecurityPosture) PreventsPushingSecrets() bool
func (*RepoSecurityPosture) ScansForSecrets ¶
func (rsp *RepoSecurityPosture) ScansForSecrets() bool
type RepositoryMetadata ¶
type RestData ¶
type RestData struct {
Config *config.Config
WorkflowsEnabled bool
WorkflowPermissions WorkflowPermissions
Insights si.SecurityInsights
InsightsError bool
Releases []ReleaseData
Rulesets []Ruleset
HttpClient HttpClient `json:"-" yaml:"-"`
// contains filtered or unexported fields
}
func (*RestData) GetDirectoryContent ¶
func (r *RestData) GetDirectoryContent(path string) (dirContent []*github.RepositoryContent, err error)
func (*RestData) GetFileContent ¶
func (r *RestData) GetFileContent(path string) (content *github.RepositoryContent, err error)
func (*RestData) GetRulesets ¶
func (*RestData) HasSupportMarkdown ¶
returns true when a file with case insensitive name matching support.md is found in the root or forge directories or when the readme.md contains a heading named "Support"
func (*RestData) IsCodeRepo ¶
IsCodeRepo returns true if the repository contains any programming languages.
TODO: Consider using GitHub Linguist metadata (https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml) to distinguish between programming, markup, data, and prose content types for more nuanced repository classification.
func (*RestData) MakeApiCall ¶
type SecurityPosture ¶
type SecurityPosture interface {
PreventsPushingSecrets() bool
ScansForSecrets() bool
DefinesPolicyForHandlingSecrets() bool
}
SecurityPosture defines an interface for accessing security-related metadata about a repository.
type WorkflowPermissions ¶
Click to show internal directories.
Click to hide internal directories.