Skip to content

Commit

Permalink
Fix xsc AuthConfig and add tech to language mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
gailazar300 committed Mar 27, 2024
1 parent b506b91 commit 32a9d5d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
10 changes: 8 additions & 2 deletions utils/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ type ServerDetails struct {
ArtifactoryUrl string `json:"artifactoryUrl,omitempty"`
DistributionUrl string `json:"distributionUrl,omitempty"`
XrayUrl string `json:"xrayUrl,omitempty"`
XscUrl string `json:"xscUrl,omitempty"`
MissionControlUrl string `json:"missionControlUrl,omitempty"`
PipelinesUrl string `json:"pipelinesUrl,omitempty"`
AccessUrl string `json:"accessUrl,omitempty"`
Expand Down Expand Up @@ -712,10 +711,17 @@ func (serverDetails *ServerDetails) CreateXrayAuthConfig() (auth.ServiceDetails,

func (serverDetails *ServerDetails) CreateXscAuthConfig() (auth.ServiceDetails, error) {
ascAuth := xscAuth.NewXscDetails()
ascAuth.SetUrl(serverDetails.XscUrl)
ascAuth.SetUrl(convertXrayUrlToXscUrl(serverDetails.XrayUrl))
return serverDetails.createAuthConfig(ascAuth)
}

// Xray ans Xsc will always have the same platform url.
func convertXrayUrlToXscUrl(xrayUrl string) string {
xscUrl := strings.TrimSuffix(xrayUrl, "/")
xscUrl = strings.TrimSuffix(xrayUrl, "xray")
return xscUrl + "xsc/"
}

func (serverDetails *ServerDetails) CreatePipelinesAuthConfig() (auth.ServiceDetails, error) {
pAuth := pipelinesAuth.NewPipelinesDetails()
pAuth.SetUrl(serverDetails.PipelinesUrl)
Expand Down
25 changes: 21 additions & 4 deletions utils/coreutils/techutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,30 @@ const (
Go Technology = "go"
Pip Technology = "pip"
Pipenv Technology = "pipenv"
Pypi Technology = "pypi"
Poetry Technology = "poetry"
Nuget Technology = "nuget"
Dotnet Technology = "dotnet"
Docker Technology = "docker"
)

const Pypi = "pypi"
func TechnologyToLanguage(technology Technology) string {
languageMap := map[Technology]string{
Npm: "JavaScript",
Pip: "Python",
Poetry: "Python",
Pipenv: "Python",
Pypi: "Python",
Go: "Go",
Maven: "Java",
Gradle: "Java",
Nuget: "C#",
Dotnet: "C#",
Yarn: "JavaScript",
Pnpm: "JavaScript",
}
return languageMap[technology]
}

type TechData struct {
// The name of the package type used in this technology.
Expand Down Expand Up @@ -107,22 +124,22 @@ var technologiesData = map[Technology]TechData{
packageInstallationCommand: "get",
},
Pip: {
packageType: Pypi,
packageType: Pypi.String(),
indicators: []string{"setup.py", "requirements.txt"},
packageDescriptors: []string{"setup.py", "requirements.txt"},
exclude: []string{"Pipfile", "Pipfile.lock", "pyproject.toml", "poetry.lock"},
applicabilityScannable: true,
},
Pipenv: {
packageType: Pypi,
packageType: Pypi.String(),
indicators: []string{"Pipfile", "Pipfile.lock"},
packageDescriptors: []string{"Pipfile"},
packageVersionOperator: "==",
packageInstallationCommand: "install",
applicabilityScannable: true,
},
Poetry: {
packageType: Pypi,
packageType: Pypi.String(),
indicators: []string{"pyproject.toml", "poetry.lock"},
packageDescriptors: []string{"pyproject.toml"},
packageInstallationCommand: "add",
Expand Down

0 comments on commit 32a9d5d

Please sign in to comment.