Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
feat: add xray to sca rules (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimabru authored Oct 12, 2022
1 parent c72f028 commit 4a63ea5
Show file tree
Hide file tree
Showing 26 changed files with 736 additions and 82 deletions.
10 changes: 5 additions & 5 deletions pkg/connectors/github/githubConnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (gc *GithubConnector) addRepo(githubJsonObject map[string]*GithubOwner, rep
FullName: *repo.FullName,
ID: int(*repo.ID),
ProgrammingLanguages: languages,
GithubActionsWorkflows: make(map[string]*PipelineFile),
JfrogPipelines: make(map[string]*PipelineFile),
GithubActionsWorkflows: make(map[string]*connectors.PipelineFile),
JfrogPipelines: make(map[string]*connectors.PipelineFile),
}

return nil
Expand Down Expand Up @@ -153,8 +153,8 @@ func (gc *GithubConnector) processWorkflowFiles(githubJsonObject map[string]*Git
return processingError
}

func (gc *GithubConnector) getWorkflowFilesEntities(repo *github.Repository) (chan *PipelineFile, error) {
workflowFilesEntitiesChan := make(chan *PipelineFile)
func (gc *GithubConnector) getWorkflowFilesEntities(repo *github.Repository) (chan *connectors.PipelineFile, error) {
workflowFilesEntitiesChan := make(chan *connectors.PipelineFile)

var getEntitiesErr error
go func() {
Expand All @@ -171,7 +171,7 @@ func (gc *GithubConnector) getWorkflowFilesEntities(repo *github.Repository) (ch
}
relevantFilesPaths := gc.matchedFiles(tree, cicdPlatform.RelevantFilesRegex)
for _, filePath := range relevantFilesPaths {
workflowFilesEntitiesChan <- &PipelineFile{
workflowFilesEntitiesChan <- &connectors.PipelineFile{
RelativePath: filePath,
Filename: path.Base(filePath),
Origin: cicdPlatform.Name,
Expand Down
21 changes: 8 additions & 13 deletions pkg/connectors/github/githubJson.type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package githubConnector

import "github.com/allero-io/allero/pkg/connectors"

type GithubOwner struct {
Name string `json:"ownerName"`
Type string `json:"ownerType"`
Expand All @@ -8,17 +10,10 @@ type GithubOwner struct {
}

type GithubRepository struct {
Name string `json:"name"`
FullName string `json:"fullName"`
ID int `json:"id"`
ProgrammingLanguages []string `json:"programmingLanguages"`
GithubActionsWorkflows map[string]*PipelineFile `json:"github-actions-workflows"`
JfrogPipelines map[string]*PipelineFile `json:"jfrog-pipelines"`
}

type PipelineFile struct {
RelativePath string `json:"relativePath"`
Filename string `json:"filename"`
Origin string `json:"origin"`
Content interface{} `json:"content"`
Name string `json:"name"`
FullName string `json:"fullName"`
ID int `json:"id"`
ProgrammingLanguages []string `json:"programmingLanguages"`
GithubActionsWorkflows map[string]*connectors.PipelineFile `json:"github-actions-workflows"`
JfrogPipelines map[string]*connectors.PipelineFile `json:"jfrog-pipelines"`
}
10 changes: 5 additions & 5 deletions pkg/connectors/gitlab/gitlabConnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func (gc *GitlabConnector) processPipelineFiles(gitlabJsonObject map[string]*Git
return processingError
}

func (gc *GitlabConnector) getPipelineFiles(project *gitlab.Project) (chan *PipelineFile, error) {
pipelineFilesChan := make(chan *PipelineFile)
func (gc *GitlabConnector) getPipelineFiles(project *gitlab.Project) (chan *connectors.PipelineFile, error) {
pipelineFilesChan := make(chan *connectors.PipelineFile)

var getEntitiesErr error
go func() {
Expand All @@ -124,7 +124,7 @@ func (gc *GitlabConnector) getPipelineFiles(project *gitlab.Project) (chan *Pipe
}
relevantFilesPaths := gc.matchedFiles(treeNodes, cicdPlatform.RelevantFilesRegex)
for _, filePath := range relevantFilesPaths {
pipelineFilesChan <- &PipelineFile{
pipelineFilesChan <- &connectors.PipelineFile{
RelativePath: filePath,
Filename: path.Base(filePath),
Origin: cicdPlatform.Name,
Expand Down Expand Up @@ -173,8 +173,8 @@ func (gc *GitlabConnector) addProject(gitlabJsonObject map[string]*GitlabGroup,
Name: projectName,
FullName: fullName,
ID: project.ID,
GitlabCi: make(map[string]*PipelineFile),
JfrogPipelines: make(map[string]*PipelineFile),
GitlabCi: make(map[string]*connectors.PipelineFile),
JfrogPipelines: make(map[string]*connectors.PipelineFile),
}

return nil
Expand Down
19 changes: 7 additions & 12 deletions pkg/connectors/gitlab/gitlabJson.type.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package gitlabConnector

import "github.com/allero-io/allero/pkg/connectors"

type GitlabGroup struct {
Name string `json:"groupName"`
ID int `json:"id"`
Projects map[string]*GitlabProject `json:"projects"`
}

type GitlabProject struct {
Name string `json:"name"`
FullName string `json:"fullName"`
ID int `json:"id"`
GitlabCi map[string]*PipelineFile `json:"gitlab-ci"`
JfrogPipelines map[string]*PipelineFile `json:"jfrog-pipelines"`
}

type PipelineFile struct {
RelativePath string `json:"relativePath"`
Filename string `json:"filename"`
Origin string `json:"origin"`
Content map[string]interface{} `json:"content"`
Name string `json:"name"`
FullName string `json:"fullName"`
ID int `json:"id"`
GitlabCi map[string]*connectors.PipelineFile `json:"gitlab-ci"`
JfrogPipelines map[string]*connectors.PipelineFile `json:"jfrog-pipelines"`
}
10 changes: 5 additions & 5 deletions pkg/connectors/local/localGithubConnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (lc *LocalConnector) addRootPathAsNewRepo(githubJsonObject map[string]*gith
FullName: escapedRepoName,
ID: 0,
ProgrammingLanguages: nil,
GithubActionsWorkflows: make(map[string]*githubConnector.PipelineFile),
JfrogPipelines: make(map[string]*githubConnector.PipelineFile),
GithubActionsWorkflows: make(map[string]*connectors.PipelineFile),
JfrogPipelines: make(map[string]*connectors.PipelineFile),
}

return nil
Expand Down Expand Up @@ -90,8 +90,8 @@ func (lc *LocalConnector) processGithubWorkflowFiles(githubJsonObject map[string
return processingError
}

func (lc *LocalConnector) getWorkflowFilesEntities(repoName string) (chan *githubConnector.PipelineFile, error) {
workflowFilesEntitiesChan := make(chan *githubConnector.PipelineFile)
func (lc *LocalConnector) getWorkflowFilesEntities(repoName string) (chan *connectors.PipelineFile, error) {
workflowFilesEntitiesChan := make(chan *connectors.PipelineFile)

var getEntitiesErr error
go func() {
Expand All @@ -106,7 +106,7 @@ func (lc *LocalConnector) getWorkflowFilesEntities(repoName string) (chan *githu
return
}
for _, filePath := range relevantFilesPaths {
workflowFilesEntitiesChan <- &githubConnector.PipelineFile{
workflowFilesEntitiesChan <- &connectors.PipelineFile{
RelativePath: filePath,
Filename: path.Base(filePath),
Origin: cicdPlatform.Name,
Expand Down
10 changes: 5 additions & 5 deletions pkg/connectors/local/localGitlabConnector.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func (lc *LocalConnector) addRootPathAsNewProject(gitlabJsonObject map[string]*g
Name: escapedRepoName,
FullName: escapedRepoName,
ID: 0,
GitlabCi: make(map[string]*gitlabConnector.PipelineFile),
JfrogPipelines: make(map[string]*gitlabConnector.PipelineFile),
GitlabCi: make(map[string]*connectors.PipelineFile),
JfrogPipelines: make(map[string]*connectors.PipelineFile),
}

return nil
Expand Down Expand Up @@ -88,8 +88,8 @@ func (lc *LocalConnector) processGitlabWorkflowFiles(gitlabJsonObject map[string
return processingError
}

func (lc *LocalConnector) getGitlabWorkflowFilesEntities(repoName string) (chan *gitlabConnector.PipelineFile, error) {
workflowFilesEntitiesChan := make(chan *gitlabConnector.PipelineFile)
func (lc *LocalConnector) getGitlabWorkflowFilesEntities(repoName string) (chan *connectors.PipelineFile, error) {
workflowFilesEntitiesChan := make(chan *connectors.PipelineFile)

var getEntitiesErr error
go func() {
Expand All @@ -108,7 +108,7 @@ func (lc *LocalConnector) getGitlabWorkflowFilesEntities(repoName string) (chan
return
}
for _, filePath := range relevantFilesPaths {
workflowFilesEntitiesChan <- &gitlabConnector.PipelineFile{
workflowFilesEntitiesChan <- &connectors.PipelineFile{
RelativePath: filePath,
Filename: path.Base(filePath),
Origin: cicdPlatform.Name,
Expand Down
7 changes: 7 additions & 0 deletions pkg/connectors/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ type CICDPlatform struct {
GitlabValid bool
}

type PipelineFile struct {
RelativePath string `json:"relativePath"`
Filename string `json:"filename"`
Origin string `json:"origin"`
Content map[string]interface{} `json:"content"`
}

var SUPPORTED_CICD_PLATFORMS = []CICDPlatform{
{
Name: "github_actions",
Expand Down
Loading

0 comments on commit 4a63ea5

Please sign in to comment.