Skip to content

Commit

Permalink
fix for linter - 5
Browse files Browse the repository at this point in the history
  • Loading branch information
miryamfoiferCX committed Sep 17, 2024
1 parent caefb91 commit 628f72a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions internal/commands/asca/asca-engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ func RunScanASCACommand(jwtWrapper wrappers.JWTWrapper, featureFlagsWrapper wrap
agent, _ := cmd.Flags().GetString(commonParams.AgentFlag)
var port = viper.GetInt(commonParams.ASCAPortKey)
ASCAWrapper := grpcs.NewASCAGrpcWrapper(port)
ASCAParams := services.ASCAScanParams{
ASCAParams := services.AscaScanParams{
FilePath: fileSourceFlag,
ASCAUpdateVersion: ASCALatestVersion,
IsDefaultAgent: agent == commonParams.DefaultAgent,
}
wrapperParams := services.ASCAWrappersParam{
wrapperParams := services.AscaWrappersParam{
JwtWrapper: jwtWrapper,
FeatureFlagsWrapper: featureFlagsWrapper,
ASCAWrapper: ASCAWrapper,
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/asca/asca-engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ func Test_ExecuteAscaScan(t *testing.T) {
for _, tt := range tests {
ttt := tt
t.Run(ttt.name, func(t *testing.T) {
ASCAParams := services.ASCAScanParams{
ASCAParams := services.AscaScanParams{
FilePath: ttt.args.fileSourceFlag,
ASCAUpdateVersion: ttt.args.ASCAUpdateVersion,
IsDefaultAgent: true,
}
wrapperParams := services.ASCAWrappersParam{
wrapperParams := services.AscaWrappersParam{
JwtWrapper: &mock.JWTMockWrapper{},
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: &mock.ASCAMockWrapper{},
Expand Down
12 changes: 6 additions & 6 deletions internal/services/asca.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ const (
FileNotFound = "File %s not found"
)

type ASCAScanParams struct {
type AscaScanParams struct {
FilePath string
ASCAUpdateVersion bool
IsDefaultAgent bool
}

type ASCAWrappersParam struct {
type AscaWrappersParam struct {
JwtWrapper wrappers.JWTWrapper
FeatureFlagsWrapper wrappers.FeatureFlagsWrapper
ASCAWrapper grpcs.AscaWrapper
}

func CreateASCAScanRequest(ascaParams ASCAScanParams, wrapperParams ASCAWrappersParam) (*grpcs.ScanResult, error) {
func CreateASCAScanRequest(ascaParams AscaScanParams, wrapperParams AscaWrappersParam) (*grpcs.ScanResult, error) {
err := manageASCAInstallation(ascaParams, wrapperParams)
if err != nil {
return nil, err
Expand Down Expand Up @@ -86,7 +86,7 @@ func executeScan(ascaWrapper grpcs.AscaWrapper, filePath string) (*grpcs.ScanRes
return ascaWrapper.Scan(fileName, sourceCode)
}

func manageASCAInstallation(ascaParams ASCAScanParams, ascaWrappers ASCAWrappersParam) error {
func manageASCAInstallation(ascaParams AscaScanParams, ascaWrappers AscaWrappersParam) error {
ASCAInstalled, _ := osinstaller.FileExists(ascaconfig.Params.ExecutableFilePath())

if !ASCAInstalled || ascaParams.ASCAUpdateVersion {
Expand Down Expand Up @@ -140,7 +140,7 @@ func setConfigPropertyQuiet(propName string, propValue int) {
}
}

func ensureASCAServiceRunning(wrappersParam ASCAWrappersParam, ascaParams ASCAScanParams) error {
func ensureASCAServiceRunning(wrappersParam AscaWrappersParam, ascaParams AscaScanParams) error {
if err := wrappersParam.ASCAWrapper.HealthCheck(); err != nil {
err = checkLicense(ascaParams.IsDefaultAgent, wrappersParam)
if err != nil {
Expand All @@ -161,7 +161,7 @@ func ensureASCAServiceRunning(wrappersParam ASCAWrappersParam, ascaParams ASCASc
return nil
}

func checkLicense(isDefaultAgent bool, wrapperParams ASCAWrappersParam) error {
func checkLicense(isDefaultAgent bool, wrapperParams AscaWrappersParam) error {
if !isDefaultAgent {
allowed, err := wrapperParams.JwtWrapper.IsAllowedEngine(params.AIProtectionType, wrapperParams.FeatureFlagsWrapper)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions internal/services/asca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
)

func TestCreateASCAScanRequest_DefaultAgent_Success(t *testing.T) {
ASCAParams := ASCAScanParams{
ASCAParams := AscaScanParams{
FilePath: "data/python-vul-file.py",
ASCAUpdateVersion: false,
IsDefaultAgent: true,
}
wrapperParams := ASCAWrappersParam{
wrapperParams := AscaWrappersParam{
JwtWrapper: &mock.JWTMockWrapper{},
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: mock.NewASCAMockWrapper(1234),
Expand All @@ -32,12 +32,12 @@ func TestCreateASCAScanRequest_DefaultAgent_Success(t *testing.T) {
}

func TestCreateASCAScanRequest_DefaultAgentAndLatestVersionFlag_Success(t *testing.T) {
ASCAParams := ASCAScanParams{
ASCAParams := AscaScanParams{
FilePath: "data/python-vul-file.py",
ASCAUpdateVersion: true,
IsDefaultAgent: true,
}
wrapperParams := ASCAWrappersParam{
wrapperParams := AscaWrappersParam{
JwtWrapper: &mock.JWTMockWrapper{},
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: mock.NewASCAMockWrapper(1234),
Expand All @@ -54,12 +54,12 @@ func TestCreateASCAScanRequest_DefaultAgentAndLatestVersionFlag_Success(t *testi

func TestCreateASCAScanRequest_SpecialAgentAndNoLicense_Fail(t *testing.T) {
specialErrorPort := 1
ASCAParams := ASCAScanParams{
ASCAParams := AscaScanParams{
FilePath: "data/python-vul-file.py",
ASCAUpdateVersion: true,
IsDefaultAgent: false,
}
wrapperParams := ASCAWrappersParam{
wrapperParams := AscaWrappersParam{
JwtWrapper: &mock.JWTMockWrapper{AIEnabled: mock.AIProtectionDisabled},
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: &mock.ASCAMockWrapper{Port: specialErrorPort},
Expand All @@ -74,13 +74,13 @@ func TestCreateASCAScanRequest_EngineRunningAndSpecialAgentAndNoLicense_Fail(t *
t.Fatalf("Failed to get available port: %v", err)
}

ASCAParams := ASCAScanParams{
ASCAParams := AscaScanParams{
FilePath: "data/python-vul-file.py",
ASCAUpdateVersion: true,
IsDefaultAgent: false,
}

wrapperParams := ASCAWrappersParam{
wrapperParams := AscaWrappersParam{
JwtWrapper: &mock.JWTMockWrapper{},
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: grpcs.NewASCAGrpcWrapper(port),
Expand All @@ -105,13 +105,13 @@ func TestCreateASCAScanRequest_EngineRunningAndDefaultAgentAndNoLicense_Success(
t.Fatalf("Failed to get available port: %v", err)
}

ASCAParams := ASCAScanParams{
ASCAParams := AscaScanParams{
FilePath: "data/python-vul-file.py",
ASCAUpdateVersion: true,
IsDefaultAgent: true,
}

wrapperParams := ASCAWrappersParam{
wrapperParams := AscaWrappersParam{
JwtWrapper: &mock.JWTMockWrapper{},
FeatureFlagsWrapper: &mock.FeatureFlagsMockWrapper{},
ASCAWrapper: grpcs.NewASCAGrpcWrapper(port),
Expand Down

0 comments on commit 628f72a

Please sign in to comment.