-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* appstore enhancements * adding tests and reorging file structure
- Loading branch information
Showing
36 changed files
with
225 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" path="FactionExtender/src"/> | ||
<classpathentry kind="lib" path="FactionExtender/target/FactionExtender-0.0.1-SNAPSHOT.jar"/> | ||
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="org.eclipse.jst.component.nondependency" value=""/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> | ||
|
||
<wb-module deploy-name="FactionExtender"> | ||
<wb-resource deploy-path="/" source-path="/FactionExtender/src"/> | ||
<wb-resource deploy-path="/" source-path="/src"/> | ||
<wb-resource deploy-path="/" source-path="/src/main/java"/> | ||
<wb-resource deploy-path="/" source-path="/src/test/java"/> | ||
|
||
</wb-module> | ||
|
||
</project-modules> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
disabled=06target | ||
eclipse.preferences.version=1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.faction.elements; | ||
|
||
import com.faction.elements.utils.Logger; | ||
import com.faction.elements.utils.Log; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
|
||
public class BaseExtension { | ||
|
||
private Logger logger; | ||
private HashMap<String,String> configs = new HashMap<>(); | ||
|
||
public BaseExtension() { | ||
logger = new Logger(); | ||
} | ||
|
||
public Logger getLogger() { | ||
return logger; | ||
} | ||
|
||
public List<Log> getLogs(){ | ||
return logger.getLogs(); | ||
} | ||
|
||
public HashMap<String,String> getConfigs(){ | ||
return this.configs; | ||
} | ||
|
||
public void setConfigs(HashMap<String,String>configs) { | ||
this.configs = configs; | ||
} | ||
|
||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.faction.elements.utils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.faction.elements.utils.Log.LEVEL; | ||
|
||
public class Logger { | ||
|
||
List<Log> logs = new ArrayList<Log>(); | ||
|
||
public void addLog(LEVEL level, Exception exception) { | ||
logs.add(new Log(level, exception)); | ||
} | ||
public void addLog(LEVEL level, String message) { | ||
logs.add(new Log(level, message)); | ||
} | ||
public List<Log> getLogs() { | ||
logs.sort((l1,l2) -> l1.getTimeStamp().compareTo(l2.getTimeStamp())); | ||
return logs; | ||
|
||
} | ||
|
||
|
||
|
||
} |
4 changes: 3 additions & 1 deletion
4
...action/extender/ApplicationInventory.java → ...action/extender/ApplicationInventory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.faction.extender; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
import com.faction.elements.utils.Log; | ||
|
||
public interface BaseInterface { | ||
/** | ||
* This function is used by Faction to set the configurations for the extension. This should not be called | ||
* locally in your classes | ||
* | ||
* @param configs | ||
*/ | ||
public void setConfigs(HashMap<String,String>configs); | ||
|
||
|
||
/** | ||
* This function is used by Faction to get all logs for the extension. This should not be called locally in | ||
* your classes | ||
* | ||
* @return List<Log> logs : Returns a list of logs that can be displayed in the Faction UI | ||
*/ | ||
public List<Log> getLogs(); | ||
|
||
|
||
} |
4 changes: 3 additions & 1 deletion
4
...faction/extender/VerificationManager.java → ...faction/extender/VerificationManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...action/extender/VulnerabilityManager.java → ...action/extender/VulnerabilityManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.faction.unittests; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.io.File; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import com.faction.elements.Assessment; | ||
import com.faction.elements.BaseExtension; | ||
import com.faction.elements.Vulnerability; | ||
import com.faction.elements.results.AssessmentManagerResult; | ||
import com.faction.elements.utils.Log; | ||
import com.faction.elements.utils.Log.LEVEL; | ||
import com.faction.extender.AssessmentManager; | ||
import com.faction.extender.AssessmentManager.Operation; | ||
|
||
|
||
|
||
public class ExtenderTestCase { | ||
|
||
@Test | ||
void test() { | ||
AssessmentManager asmtMgr = new MyAssmtMgr(); | ||
HashMap<String,String>configs = new HashMap<>(); | ||
configs.put("Test1", "Test Config 1"); | ||
configs.put("Test2", "Test Config 2"); | ||
|
||
asmtMgr.setConfigs(configs); | ||
|
||
Assessment asmt = new Assessment(); | ||
asmt.setSummary("Default"); | ||
|
||
Vulnerability vuln = new Vulnerability(); | ||
List<Vulnerability> vulns = new ArrayList<>(); | ||
vulns.add(vuln); | ||
|
||
AssessmentManagerResult result = asmtMgr.assessmentChange(asmt, vulns, Operation.Create); | ||
|
||
assertTrue(result.getAssessment().getSummary().equals("This is a test")); | ||
|
||
assertTrue(asmtMgr.getLogs().size() == 2); | ||
|
||
List<Log> logs = asmtMgr.getLogs(); | ||
assertTrue(logs.stream().anyMatch( log -> log.getMessage().equals("Got Config1: Test Config 1"))); | ||
assertTrue(logs.stream().anyMatch( log -> log.getMessage().equals("Got Config2: Test Config 2"))); | ||
|
||
|
||
|
||
assertTrue(true); | ||
|
||
} | ||
|
||
public class MyAssmtMgr extends BaseExtension implements AssessmentManager{ | ||
|
||
@Override | ||
public AssessmentManagerResult assessmentChange(Assessment asmt, List<Vulnerability> vulns, | ||
Operation Operation) { | ||
String config1 = this.getConfigs().get("Test1"); | ||
String config2 = this.getConfigs().get("Test2"); | ||
|
||
asmt.setSummary("This is a test"); | ||
|
||
this.getLogger().addLog(LEVEL.INFO, "Got Config1: " + config1); | ||
this.getLogger().addLog(LEVEL.INFO, "Got Config2: " + config2); | ||
|
||
AssessmentManagerResult result = new AssessmentManagerResult(); | ||
result.setAssessment(asmt); | ||
result.setVulnerabilities(vulns); | ||
return result; | ||
} | ||
} | ||
|
||
} | ||
|
||
|