Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors for Instrumentation regarding Pointcuts #30

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static void checkFileSystemInteraction(
String[] allowedPaths = (String[]) getValueFromSettings(
switch (action) {
case "read" -> "pathsAllowedToBeRead";
case "write" -> "pathsAllowedToBeOverwritten";
case "overwrite" -> "pathsAllowedToBeOverwritten";
case "execute" -> "pathsAllowedToBeExecuted";
case "delete" -> "pathsAllowedToBeDeleted";
default -> throw new IllegalArgumentException("Unknown action: " + action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ static ElementMatcher<MethodDescription> getMethodsMatcher(
"java.io.Win32FileSystem",
List.of("createFileExclusively", "delete", "setLastModifiedTime", "createDirectory"),
"java.util.prefs.FileSystemPreferences",
List.of("lockFile0", "unlockFile0")
List.of("lockFile0", "unlockFile0"),
"java.nio.file.Files",
List.of("write", "writeString", "newOutputStream", "writeBytes", "writeAllBytes", "writeLines")

);
//</editor-fold>

Expand All @@ -173,7 +176,9 @@ static ElementMatcher<MethodDescription> getMethodsMatcher(
"java.io.WinNTFileSystem",
List.of("checkAccess", "setReadOnly"),
"java.io.Win32FileSystem",
List.of("checkAccess", "setReadOnly")
List.of("checkAccess", "setReadOnly"),
"java.nio.file.Files",
List.of("setPosixFilePermissions")
);
//</editor-fold>

Expand All @@ -184,7 +189,9 @@ static ElementMatcher<MethodDescription> getMethodsMatcher(
*/
public static final Map<String, List<String>> methodsWhichCanDeleteFiles = Map.of(
"java.io.File",
List.of("delete", "deleteOnExit")
List.of("delete", "deleteOnExit"),
"java.nio.file.Files",
List.of("delete")
);
//</editor-fold>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import de.tum.cit.ase.ares.api.util.FileTools;

import java.io.File;
import java.nio.file.Path;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ private Set<JavaAccess<?>> getAccessesFromClass(JavaClass javaClass, String meth
.getOrigin()
.getFullName()
.substring(javaClass.getFullName().length())
.equals(methodName)
&& isExceptionOrError(a.getTargetOwner()))
.equals(methodName))
.collect(toSet());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class JupiterSecurityExtension implements UnifiedInvocationIntercep
public <T> T interceptGenericInvocation(Invocation<T> invocation, ExtensionContext extensionContext,
Optional<ReflectiveInvocationContext<?>> invocationContext) throws Throwable {
JupiterContext testContext = JupiterContext.of(extensionContext);

/**
* Check if the test method has the {@link Policy} annotation. If it does, read
* the policy file and run the security test cases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,6 @@ public void executeSecurityTestCases() {
@Nonnull JavaClasses classes = new ClassFileImporter().importPath(Paths.get(ProjectSourcesFinder.isGradleProject() ? "build" : "target", projectPath.toString()).toString());
//</editor-fold>#

//<editor-fold desc="Set ArchUnit properties for optimization">
ArchConfiguration.get().setProperty("archRule.failOnEmptyShould", "false");
ArchConfiguration.get().setResolveMissingDependenciesFromClassPath(false);
//</editor-fold>

//<editor-fold desc="Enforce fixed rules code">
JavaArchitectureTestCaseCollection.NO_CLASSES_SHOULD_USE_REFLECTION.check(classes);
JavaArchitectureTestCaseCollection.NO_CLASSES_SHOULD_TERMINATE_JVM.check(classes);
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/archunit.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set to false to ignore missing dependencies in the classpath, as they are resolved manually by the de.tum.cit.ase.ares.api.architecturea.archunit.postcompile.CustomClassResolver
resolveMissingDependenciesFromClassPath=false
archRule.failOnEmptyShould=false
Loading