Skip to content

Commit 1b37ff7

Browse files
GeneXus compression module (#874)
* Compress EXO initial module outline * Initial implementation of the compress method * Initial decompress functionality implementation * Add Compression data type * All 4 compression and decompression methods working * Refactor into compression package * Logging and return values for better flow control * Switch compression format type form enum to string * Change parameter types to basic ones * Various fixes * Change junit version * Fix error codes * Correct parameters data types * Expand error codes * Better logging * Remove unnecesary usage of List<File> * Add jar support * Add support for decompressing rar files * Remove unused imports * Merge nested ifs * Change operations return type * Fix method naming and logging * Make attributes readonly * Refactor compression classes to support error messages * Add missing message and fix interface return type * Refactor for better code quality * Remove unused imports * Improve error message for invalid compression format * Refactor compression classes to use ArrayList instead of Vector * Refactor compression interface to use ArrayList instead of Vector * Switch from map to set of attributes * Update gxcompress dependencies and refactor compression classes * Remove unused imports * Consider folder within files to compress for jar and zip formats * Compression module simplification an improvements * Prevent directory traversal attack * Add check for DoS attack and clear error messages * Fix compilation error * Fix gz compression and decompression issues * Remove unused imports * Remove unused import and usage of deprecated method * Prevent slips, traversals and bombs * Add compression utils * Fix wrong directory traversal and zip bomb checks * Complete rewrite of security checks, read values from given configuration * Fix clear method * Remove not empty constructor * Create gzip decompression directory if its not there * Improvements and optimizations
1 parent 2d6ec75 commit 1b37ff7

File tree

7 files changed

+1308
-8
lines changed

7 files changed

+1308
-8
lines changed

gxcompress/pom.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.genexus</groupId>
8+
<artifactId>parent</artifactId>
9+
<version>${revision}${changelist}</version>
10+
</parent>
11+
12+
<artifactId>gxcompress</artifactId>
13+
<name>GeneXus compression and decompression module</name>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.apache.commons</groupId>
18+
<artifactId>commons-compress</artifactId>
19+
<version>1.27.1</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.tukaani</groupId>
23+
<artifactId>xz</artifactId>
24+
<version>1.10</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.apache.logging.log4j</groupId>
28+
<artifactId>log4j-core</artifactId>
29+
<version>${log4j.version}</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.apache.logging.log4j</groupId>
33+
<artifactId>log4j-api</artifactId>
34+
<version>${log4j.version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>${project.groupId}</groupId>
38+
<artifactId>gxcommon</artifactId>
39+
<version>${project.version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.genexus</groupId>
43+
<artifactId>gxclassR</artifactId>
44+
<version>${project.version}</version>
45+
<scope>test</scope>
46+
</dependency>
47+
</dependencies>
48+
49+
</project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.genexus.compression;
2+
3+
import com.genexus.GXBaseCollection;
4+
import com.genexus.SdtMessages_Message;
5+
6+
import java.util.ArrayList;
7+
8+
public class Compression {
9+
10+
private String destinationPath;
11+
private CompressionConfiguration compressionConfiguration;
12+
private GXBaseCollection<SdtMessages_Message>[] messages;
13+
private ArrayList<String> filesToCompress;
14+
15+
public Compression() {}
16+
17+
public Compression(String destinationPath, CompressionConfiguration configuration, GXBaseCollection<SdtMessages_Message>[] messages) {
18+
this.destinationPath = destinationPath;
19+
this.compressionConfiguration = configuration;
20+
this.messages = messages;
21+
filesToCompress = new ArrayList<>();
22+
}
23+
24+
public void setDestinationPath(String path) {
25+
this.destinationPath = path;
26+
}
27+
28+
public void addElement(String filePath) {
29+
filesToCompress.add(filePath);
30+
}
31+
32+
public Boolean save() {
33+
return GXCompressor.compress(filesToCompress, destinationPath, compressionConfiguration, messages);
34+
}
35+
36+
public void clear() {
37+
destinationPath = "";
38+
filesToCompress = new ArrayList<>();
39+
messages = null;
40+
compressionConfiguration = new CompressionConfiguration();
41+
}
42+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.genexus.compression;
2+
3+
public class CompressionConfiguration {
4+
public long maxCombinedFileSize = -1;
5+
public long maxIndividualFileSize = -1;
6+
public int maxFileCount = -1;
7+
public String targetDirectory = "";
8+
9+
public CompressionConfiguration() {}
10+
}

0 commit comments

Comments
 (0)