Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberrolandvaltech committed Sep 28, 2020
2 parents 6851a57 + 770d45b commit 2d7619d
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 11 deletions.
5 changes: 5 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2020-09-28 1.0.1
- Mail service configuration optional
- Enhanced history


2020-08-21 1.0.0
- Enhanced history

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ You can see an example for each configuration in [example package](/examples/src
## AVS Post Filter

This filter can scan e.g. asset uploads for viruses.
You will also need to configure "Day CQ Mail Service" (com.day.cq.mailer.DefaultMailService) for this.

* includePatterns: List of regular expressions to match the URLs to check. If empty, all non-excluded URLs are scanned.
* excludePatterns: List of regular expressions to match the URLs to ignore. Has higher priority than include patterns.
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.valtech.avs</groupId>
<artifactId>avs</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<artifactId>avs.api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.valtech.avs</groupId>
<artifactId>avs</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<artifactId>avs.core</artifactId>
Expand Down
16 changes: 15 additions & 1 deletion core/src/main/java/de/valtech/avs/core/filter/AvsPostFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
continue;
}
if (StringUtils.isNotEmpty(part.getSubmittedFileName())) {
fileNames.add(part.getSubmittedFileName());
fileNames.add(getFilePath(slingRequest, part));
}
InputStream partStream = part.getInputStream();
File file = File.createTempFile("valtech-avs", ".tmp");
Expand Down Expand Up @@ -178,6 +178,20 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
chain.doFilter(request, response);
}

/**
* Returns path and name of uploaded file.
*
* @param slingRequest request
* @param part file part
* @return path
*/
private String getFilePath(SlingHttpServletRequest slingRequest, Part part) {
String fileName = part.getSubmittedFileName();
String path = (StringUtils.isNotBlank(slingRequest.getRequestURI())) ? slingRequest.getRequestURI() + "/" : "";
path = path.replace(".createasset.html", "");
return path + fileName;
}

/**
* Checks if the request is multipart form-data.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.osgi.service.metatype.annotations.Designate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -53,7 +55,7 @@ public class AvsNotificationMailer {

private static final Logger LOG = LoggerFactory.getLogger(AvsNotificationMailer.class);

@Reference
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policyOption = ReferencePolicyOption.GREEDY)
private MailService mailService;

private AvsNotificationMailerConfig config;
Expand All @@ -76,6 +78,10 @@ public void activate(AvsNotificationMailerConfig config) {
* @param result scan result
*/
public void sendEmail(List<String> emails, String fileName, ScanResult result) {
if (mailService == null) {
LOG.info("Skipping email sending as mail service is not configured.");
return;
}
VelocityEngine ve = new VelocityEngine();
ve.init();
VelocityContext context = new VelocityContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void init() {
if (inputStream != null) {
scanDone = true;
String userId = request.getResourceResolver().adaptTo(Session.class).getUserID();
ScanResult result = avsService.scan(inputStream, userId);
ScanResult result = avsService.scan(inputStream, userId, filePart.getSubmittedFileName());
clean = result.isClean();
resultOutput = result.getOutput();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.valtech.avs</groupId>
<artifactId>avs</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<artifactId>avs.examples</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>de.valtech.avs</groupId>
<artifactId>avs</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<version>1.0.1</version>
<name>AVS</name>
<description>AEM Virus Scan</description>
<url>https://github.com/valtech/aem-virus-scan</url>
Expand Down Expand Up @@ -341,7 +341,7 @@
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>5.2.1</version>
<version>5.2.4</version>
<configuration>
<failBuildOnCVSS>0</failBuildOnCVSS>
<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.projectKey=avs
sonar.projectName=AEM Virus Scan
sonar.projectVersion=1.0.0-SNAPSHOT
sonar.projectVersion=1.0.1-SNAPSHOT

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
Expand Down
2 changes: 1 addition & 1 deletion ui.apps.structure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.valtech.avs</groupId>
<artifactId>avs</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<artifactId>ui.apps.structure</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ui.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>de.valtech.avs</groupId>
<artifactId>avs</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>

<artifactId>avs.ui.apps</artifactId>
Expand Down

0 comments on commit 2d7619d

Please sign in to comment.