Skip to content

Commit

Permalink
Change file constant names
Browse files Browse the repository at this point in the history
  • Loading branch information
sarpsahinalp committed Nov 26, 2024
1 parent 4950299 commit 536233d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
public class FileHandlerConstants {

//<editor-fold desc="Java ArchUnit Methods">
public static final Path JAVA_FILESYSTEM_INTERACTION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "file-system-access-methods.txt");
public static final Path JAVA_NETWORK_ACCESS_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "network-access-methods.txt");
public static final Path JAVA_JVM_TERMINATION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "jvm-termination-methods.txt");
public static final Path JAVA_REFLECTION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "reflection-methods.txt");
public static final Path JAVA_COMMAND_EXECUTION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "command-execution-methods.txt");
public static final Path JAVA_THREAD_MANIPULATION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "thread-manipulation-methods.txt");
public static final Path JAVA_SERIALIZATION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "serializable-methods.txt");
public static final Path ARCHUNIT_FILESYSTEM_INTERACTION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "file-system-access-methods.txt");
public static final Path ARCHUNIT_NETWORK_ACCESS_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "network-access-methods.txt");
public static final Path ARCHUNIT_JVM_TERMINATION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "jvm-termination-methods.txt");
public static final Path ARCHUNIT_REFLECTION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "reflection-methods.txt");
public static final Path ARCHUNIT_COMMAND_EXECUTION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "command-execution-methods.txt");
public static final Path ARCHUNIT_THREAD_MANIPULATION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "thread-manipulation-methods.txt");
public static final Path ARCHUNIT_SERIALIZATION_METHODS = FileTools.resolveOnResources("templates", "architecture" , "java", "archunit", "methods", "serializable-methods.txt");
//</editor-fold>

//<editor-fold desc="WALA Methods">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.stream.Collectors;

import static de.tum.cit.ase.ares.api.architecture.java.JavaArchitectureTestCase.parseErrorMessage;
import static de.tum.cit.ase.ares.api.architecture.java.archunit.JavaArchitectureTestCaseCollection.getArchitectureRuleFileContent;
import static de.tum.cit.ase.ares.api.architecture.java.archunit.JavaArchUnitTestCaseCollection.getArchitectureRuleFileContent;
import static de.tum.cit.ase.ares.api.localization.Messages.localized;
//</editor-fold>

Expand Down Expand Up @@ -78,35 +78,35 @@ public void executeArchitectureTestCase(JavaClasses javaClasses) {
try {
switch (this.javaArchitectureTestCaseSupported) {
case FILESYSTEM_INTERACTION ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASS_SHOULD_ACCESS_FILE_SYSTEM
.check(javaClasses);
case NETWORK_CONNECTION ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASSES_SHOULD_ACCESS_NETWORK
.check(javaClasses);
case THREAD_CREATION ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASSES_SHOULD_CREATE_THREADS
.check(javaClasses);
case COMMAND_EXECUTION ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASSES_SHOULD_EXECUTE_COMMANDS
.check(javaClasses);
case PACKAGE_IMPORT ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.noClassesShouldImportForbiddenPackages(allowedPackages)
.check(javaClasses);
case REFLECTION ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASSES_SHOULD_USE_REFLECTION
.check(javaClasses);
case TERMINATE_JVM ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASSES_SHOULD_TERMINATE_JVM
.check(javaClasses);
case SERIALIZATION ->
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.NO_CLASSES_SHOULD_SERIALIZE
.check(javaClasses);
// Classloading included in the Reflection test case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
/**
* This class runs the security rules on the architecture for the post-compile mode.
*/
public class JavaArchitectureTestCaseCollection {
public class JavaArchUnitTestCaseCollection {

//<editor-fold desc="Constructor">
private JavaArchitectureTestCaseCollection() {
throw new IllegalArgumentException("Ares Security Error (Reason: Ares-Code; Stage: Execution): JavaArchitectureTestCaseCollection is a utility class and should not be instantiated.");
private JavaArchUnitTestCaseCollection() {
throw new SecurityException(localize("security.general.utility.initialization", JavaArchUnitTestCaseCollection.class.getName()));
}
//</editor-fold>

Expand All @@ -41,7 +41,7 @@ public static String getArchitectureRuleFileContent(String key) {
"templates", "architecture", "java", "archunit", "rules", key + ".txt");

// Read the file content
try (InputStream sourceStream = JavaArchitectureTestCaseCollection.class.getResourceAsStream("/" + resolvedPath)) {
try (InputStream sourceStream = JavaArchUnitTestCaseCollection.class.getResourceAsStream("/" + resolvedPath)) {
if (sourceStream == null) {
throw new IOException("Resource not found: " + resolvedPath);
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public boolean test(JavaAccess<?> javaAccess) {
*/
public static final ArchRule NO_CLASS_SHOULD_ACCESS_FILE_SYSTEM = createNoClassShouldHaveMethodRule(
localize("security.architecture.file.system.access"),
FileHandlerConstants.JAVA_FILESYSTEM_INTERACTION_METHODS
FileHandlerConstants.ARCHUNIT_FILESYSTEM_INTERACTION_METHODS
);
//</editor-fold>

Expand All @@ -97,21 +97,21 @@ public boolean test(JavaAccess<?> javaAccess) {
*/
public static final ArchRule NO_CLASSES_SHOULD_ACCESS_NETWORK = createNoClassShouldHaveMethodRule(
localize("security.architecture.network.access"),
FileHandlerConstants.JAVA_NETWORK_ACCESS_METHODS
FileHandlerConstants.ARCHUNIT_NETWORK_ACCESS_METHODS
);
//</editor-fold>

//<editor-fold desc="Thread Creation related rule">
public static final ArchRule NO_CLASSES_SHOULD_CREATE_THREADS = createNoClassShouldHaveMethodRule(
localize("security.architecture.manipulate.threads"),
FileHandlerConstants.JAVA_THREAD_MANIPULATION_METHODS
FileHandlerConstants.ARCHUNIT_THREAD_MANIPULATION_METHODS
);
//</editor-fold>

//<editor-fold desc="Command Execution related rule">
public static final ArchRule NO_CLASSES_SHOULD_EXECUTE_COMMANDS = createNoClassShouldHaveMethodRule(
localize("security.architecture.execute.command"),
FileHandlerConstants.JAVA_COMMAND_EXECUTION_METHODS
FileHandlerConstants.ARCHUNIT_COMMAND_EXECUTION_METHODS
);
//</editor-fold>

Expand All @@ -138,7 +138,7 @@ public boolean test(JavaClass javaClass) {
*/
public static final ArchRule NO_CLASSES_SHOULD_USE_REFLECTION = createNoClassShouldHaveMethodRule(
localize("security.architecture.reflection.uses"),
FileHandlerConstants.JAVA_REFLECTION_METHODS
FileHandlerConstants.ARCHUNIT_REFLECTION_METHODS
);
//</editor-fold>

Expand All @@ -148,14 +148,14 @@ public boolean test(JavaClass javaClass) {
*/
public static final ArchRule NO_CLASSES_SHOULD_TERMINATE_JVM = createNoClassShouldHaveMethodRule(
localize("security.architecture.terminate.jvm"),
FileHandlerConstants.JAVA_JVM_TERMINATION_METHODS
FileHandlerConstants.ARCHUNIT_JVM_TERMINATION_METHODS
);
//</editor-fold>

//<editor-fold desc="Serialization related rule">
public static final ArchRule NO_CLASSES_SHOULD_SERIALIZE = createNoClassShouldHaveMethodRule(
localize("security.architecture.serialize"),
FileHandlerConstants.JAVA_SERIALIZATION_METHODS
FileHandlerConstants.ARCHUNIT_SERIALIZATION_METHODS
);
//</editor-fold>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.ibm.wala.shrike.shrikeCT.InvalidClassFileException;
import com.tngtech.archunit.core.domain.JavaClasses;
import de.tum.cit.ase.ares.api.architecture.java.FileHandlerConstants;
import de.tum.cit.ase.ares.api.architecture.java.archunit.JavaArchitectureTestCaseCollection;
import de.tum.cit.ase.ares.api.architecture.java.archunit.JavaArchUnitTestCaseCollection;

import java.nio.file.Path;
import java.util.List;
Expand Down Expand Up @@ -125,7 +125,7 @@ public static void noCommandExecution(CallGraph cg) {

//<editor-fold desc="Package Import related rule">
public static void restrictPackageImport(JavaClasses javaClasses, Set<String> allowedPackages) {
JavaArchitectureTestCaseCollection
JavaArchUnitTestCaseCollection
.noClassesShouldImportForbiddenPackages(allowedPackages)
.check(javaClasses);
}
Expand Down

0 comments on commit 536233d

Please sign in to comment.