Skip to content

Commit

Permalink
CXFLW-993 CXFLW-1128 documentation and added zip utils test case (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
satyamchaurasiapersistent authored Jan 25, 2024
1 parent 2864984 commit 857f7a9
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 43 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
ext {

CxSBSDK = "0.5.69"
CxSBSDK = "0.5.70"


ConfigProviderVersion = "1.0.10"
Expand Down Expand Up @@ -94,7 +94,7 @@ dependencies {
exclude group: 'org.apache.logging.log4j', module: 'log4j-core'
exclude group: 'ch.qos.logback', module: 'logback-core'
}

compile('org.springframework.boot:spring-boot-starter-aop'){
exclude group: 'ch.qos.logback', module: 'logback-core'
}
Expand Down Expand Up @@ -187,7 +187,7 @@ dependencies {
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:${junitVersion}")
testImplementation 'org.mockito:mockito-core:4.11.0'

testCompile("net.bytebuddy:byte-buddy:1.12.9") //Added due to Mockito Exception.Normally, Gradle should take care class path completion.
testCompile("net.bytebuddy:byte-buddy:1.12.9") //Added due to Mockito Exception.Normally, Gradle should take care class path completion.
compile("org.projectlombok:lombok:1.18.10")
compile("ch.qos.logback:logback-classic:1.2.13"){
exclude group: 'ch.qos.logback', module: 'logback-core'
Expand All @@ -206,7 +206,7 @@ dependencies {
exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
exclude group: 'org.apache.logging.log4j', module: 'log4j-core'

}
compile("org.apache.logging.log4j:log4j-core:2.17.1")
compile("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1")
Expand Down
6 changes: 5 additions & 1 deletion docs/Frequently-Asked-Questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* [Can a single yaml file be used to connect to multiple defect tracking systems?](#singleyaml)
* [How do you manage the project creation within CxSAST when running CxFlow in WebHook mode?](#manageprojectcreation)
* [If using global WebHooks, can specific projects be excluded from scanning?](#globalwebhooks)
* [Why cxflow spring boot fails to start application if application.xml is present in source code in GitLab pipeline](#applicationxml)

## <a name="whatiscxflow">Q: What is CxFlow?</a>
CxFlow is a solution that enables creating projects automatically, scans orchestration and facilitates feedback channels in a closed loop mode.
Expand Down Expand Up @@ -103,4 +104,7 @@ Yes - with the limitation of one Jira instance.
Overrides can be used to assign the same name to multiple projects. Alternatively, a groovy script can be used to help decide on project names and if it should be scanned. Refer also to [CxFlow Configuration](https://github.com/checkmarx-ltd/cx-flow/wiki/Configuration)

## <a name="globalwebhooks">Q: If using global WebHooks, can specific projects be excluded from scanning?</a>
Yes, this can be performed with overrides & [Config As Code](https://github.com/checkmarx-ltd/cx-flow/wiki/Config-As-Code)
Yes, this can be performed with overrides & [Config As Code](https://github.com/checkmarx-ltd/cx-flow/wiki/Config-As-Code)

## <a name="applicationxml">Q: Why cxflow spring boot fails to start application if application.xml is present in source code in GitLab pipeline ?</a>
Plesae pass command line parameter --spring.config.name=myproject in .gitlab-ci.yml file
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@
import com.checkmarx.flow.dto.ScanRequest;
import com.checkmarx.flow.exception.MachinaException;
import com.checkmarx.flow.service.FilenameFormatter;
import com.checkmarx.flow.utils.JAXBHelper;
import com.checkmarx.flow.utils.ScanUtils;
import com.checkmarx.sdk.dto.ScanResults;
import com.checkmarx.sdk.dto.sca.SCAResults;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import javax.xml.bind.JAXBException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/com/checkmarx/flow/utils/JAXBHelper.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/com/checkmarx/flow/utils/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class ZipUtils {
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;

private ZipUtils() {
public ZipUtils() {
}

public static File zipToTempFile(String fileToZip, String excludePatterns) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.checkmarx.flow.cucumber.integration.ziputils;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = { "pretty", "summary", "html:build/integration/ziputils", "json:build/cucumber/features/integration/ziputils" },
features = "src/test/resources/cucumber/features",
glue = { "com.checkmarx.flow.cucumber.integration.ziputils"},
tags = "@Ziputils and @Integration and not @Skip")
public class RunZipUtilsTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.checkmarx.flow.cucumber.integration.ziputils;

import com.checkmarx.flow.utils.ZipUtils;
import io.cucumber.java.en.And;
import io.cucumber.java.en.When;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertTrue;

@Slf4j
public class zipUtilsSteps {


@When("Creating zip File at a time")
public void testZipFileSuccess() throws IOException {
// Creating Zip File
ZipUtils zipService = new ZipUtils();
File zippedFile = zipService.zipToTempFile(".","");

// Checking presence of zip file
assertTrue(zippedFile.exists());
assertTrue(zippedFile.length() >= 1); // Adjust based on size of your file

// Deleting zip file
boolean deleted = zippedFile.delete();

if (deleted) {
log.info("File successfully deleted!");
} else {
log.info("Error deleting file.");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@Ziputils
@Integration
Feature: Zipping files

Scenario: Zip a file created and deleted successfully
When Creating zip File at a time



0 comments on commit 857f7a9

Please sign in to comment.