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

chore: disallow Log4j #618

Merged
merged 4 commits into from
Feb 3, 2021
Merged
Changes from 1 commit
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
Next Next commit
chore: disallow Log4j
  • Loading branch information
sullis committed Jan 30, 2021
commit a1f70fc03514d32ce409e5809ab65a82396b666c
17 changes: 17 additions & 0 deletions src/test/java/com/twilio/compliance/ComplianceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.core.importer.ImportOptions;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.syntax.elements.GivenClassesConjunction;

import nl.jqno.equalsverifier.EqualsVerifier;

import static com.tngtech.archunit.core.domain.JavaClass.Predicates.resideInAPackage;
import static com.tngtech.archunit.lang.conditions.ArchConditions.dependOnClassesThat;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.noClasses;
import static com.tngtech.archunit.library.GeneralCodingRules.*;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -45,6 +49,14 @@ public void noClassesShouldUseJavaUtilLogging() {
NO_CLASSES_SHOULD_USE_JAVA_UTIL_LOGGING.check(twilioClasses);
}

@Test
public void noClassesShouldUseLog4j() {
// disallow Log4j version 1.x
disallowPackage("org.apache.log4j").check(twilioClasses);
// disallow Log4j version 2.x
disallowPackage("org.apache.logging.log4j").check(twilioClasses);
}

@Test
public void noClassesShouldUseJodaTime() {
NO_CLASSES_SHOULD_USE_JODATIME.check(twilioClasses);
Expand Down Expand Up @@ -73,4 +85,9 @@ private static List<Class> getResourceClasses(final JavaClasses jclasses) {
}
return Collections.unmodifiableList(builder);
}

private static ArchRule disallowPackage(final String packageIdentifier) {
return noClasses()
.should(dependOnClassesThat(resideInAPackage(packageIdentifier)));
}
}