Skip to content

Commit

Permalink
Merge pull request #55 from checkmarx-ltd/fix-logger
Browse files Browse the repository at this point in the history
revert log4j.xml exclude from jar and raise version to 2020.4.3
  • Loading branch information
ghannamz authored Oct 7, 2020
2 parents c7306d9 + a56fd1e commit 2119211
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.cx.plugin</groupId>
<artifactId>CxConsolePlugin</artifactId>
<version>2020.4.2</version>
<version>2020.4.3</version>
<packaging>jar</packaging>

<repositories>
Expand Down Expand Up @@ -71,7 +71,6 @@
<version>3.1.2</version>
<configuration>
<excludes>
<exclude>**/log4j.xml</exclude>
<exclude>**/*.cmd</exclude>
<exclude>**/*.sh</exclude>
</excludes>
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/com/cx/plugin/cli/CxConsoleLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
import org.apache.http.Consts;
import org.apache.log4j.Appender;
import org.apache.log4j.Level;
import org.slf4j.Logger;
import org.apache.log4j.Logger;
import org.apache.log4j.RollingFileAppender;
import org.apache.log4j.xml.DOMConfigurator;
import org.slf4j.LoggerFactory;
import org.slf4j.impl.Log4jLoggerFactory;

import java.io.*;
Expand All @@ -39,7 +38,7 @@
*/
public class CxConsoleLauncher {

private static Logger log = LoggerFactory.getLogger(CxConsoleLauncher.class);
private static Logger log = Logger.getLogger(CxConsoleLauncher.class);

public static void main(String[] args) {
int exitCode;
Expand Down Expand Up @@ -82,7 +81,7 @@ private static String[] overrideProperties(String[] args) {

if (propFilePath != null) {
try {
log.info("Overriding properties from file: {}", propFilePath);
log.info("Overriding properties from file: " + propFilePath);
String argsStr = IOUtils.toString(new FileInputStream(propFilePath), Consts.UTF_8);
args = argsStr.split("\\s+");
} catch (Exception e) {
Expand All @@ -104,17 +103,17 @@ private static int execute(Command command, CommandLine commandLine)
org.slf4j.Logger logger = new Log4jLoggerFactory().getLogger(log.getName());
CxSastConnectionProvider connectionProvider = new CxSastConnectionProvider(cxScanConfig, logger);

CxClientDelegator clientDelegator = new CxClientDelegator(cxScanConfig, log);
CxClientDelegator clientDelegator = new CxClientDelegator(cxScanConfig, logger);
clientDelegator.init();

if (command.equals(Command.TEST_CONNECTION)) {
if (cxScanConfig.getAstScaConfig() != null) {
String accessControlUrl = cxScanConfig.getAstScaConfig().getAccessControlUrl();
log.info("Testing connection to: {}", accessControlUrl);
log.info("Testing connection to: " + accessControlUrl);
clientDelegator.getScaClient().testScaConnection();
} else {
String url = cxScanConfig.getUrl();
log.info("Testing connection to: {}", url);
log.info("Testing connection to: " + url);
connectionProvider.login();
}
log.info("Login successful");
Expand All @@ -125,7 +124,7 @@ private static int execute(Command command, CommandLine commandLine)
if (cxTokenExists(commandLine)) {
String token = cxScanConfig.getRefreshToken();
token = DigestUtils.sha256Hex(token);
log.info("Revoking access token: {}", token);
log.info("Revoking access token: " + token);
connectionProvider.revokeToken(cxScanConfig.getRefreshToken());
return exitCode;
} else {
Expand All @@ -138,7 +137,7 @@ private static int execute(Command command, CommandLine commandLine)
if (command.equals(Command.GENERATE_TOKEN)) {
if (userPasswordProvided(commandLine)) {
String token = connectionProvider.getToken();
log.info("The login token is: {}", token);
log.info("The login token is: " + token);
return exitCode;
} else {
log.error("-CxUser and -CxPassword flags are missing.");
Expand Down Expand Up @@ -243,7 +242,7 @@ private static void initLogging(CommandLine commandLine) throws CLIParsingExcept
((RollingFileAppender) faAppender).setThreshold(Level.TRACE);
}
((RollingFileAppender) faAppender).setWriter(writer);
log.info("[CxConsole] Log file location: {}", logPath);
log.info("[CxConsole] Log file location: " + logPath);
} catch (IOException e) {
throw new CLIParsingException("[CxConsole] error creating log file", e);
}
Expand Down

0 comments on commit 2119211

Please sign in to comment.