From 628f72a5fa0815ae8297ebd64d5afd27c03773a6 Mon Sep 17 00:00:00 2001 From: miryamfoiferCX Date: Tue, 17 Sep 2024 11:52:35 +0300 Subject: [PATCH] fix for linter - 5 --- internal/commands/asca/asca-engine.go | 4 ++-- internal/commands/asca/asca-engine_test.go | 4 ++-- internal/services/asca.go | 12 ++++++------ internal/services/asca_test.go | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/internal/commands/asca/asca-engine.go b/internal/commands/asca/asca-engine.go index dcd9b49ac..fc851378c 100644 --- a/internal/commands/asca/asca-engine.go +++ b/internal/commands/asca/asca-engine.go @@ -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, diff --git a/internal/commands/asca/asca-engine_test.go b/internal/commands/asca/asca-engine_test.go index dd26a9253..cbc09cf9e 100644 --- a/internal/commands/asca/asca-engine_test.go +++ b/internal/commands/asca/asca-engine_test.go @@ -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{}, diff --git a/internal/services/asca.go b/internal/services/asca.go index 6fd832614..2749f40d6 100644 --- a/internal/services/asca.go +++ b/internal/services/asca.go @@ -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 @@ -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 { @@ -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 { @@ -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 { diff --git a/internal/services/asca_test.go b/internal/services/asca_test.go index b27e06bff..8ef5d6bf5 100644 --- a/internal/services/asca_test.go +++ b/internal/services/asca_test.go @@ -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), @@ -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), @@ -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}, @@ -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), @@ -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),