-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature-3233-improve-pds-solution-prepare
# Conflicts: # sechub-wrapper-prepare/src/main/java/com/mercedesbenz/sechub/wrapper/prepare/cli/PrepareWrapperCLI.java
- Loading branch information
Showing
77 changed files
with
1,690 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...e/src/main/java/com/mercedesbenz/sechub/commons/archive/ArchiveExtractionConstraints.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.commons.archive; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.time.Duration; | ||
import java.util.Objects; | ||
|
||
/** | ||
* The ArchiveExtractionConstraints class encapsulates the properties used to | ||
* safeguard the extraction of an archive when using the | ||
* {@link SafeArchiveInputStream}. These properties include maximum uncompressed | ||
* file size, maximum number of entries, maximum directory depth, and timeout. | ||
* | ||
* <p> | ||
* Each property is validated during the creation of an | ||
* ArchiveExtractionConstraints object to ensure they meet the required | ||
* conditions. | ||
* | ||
* <p> | ||
* Example usage: | ||
* | ||
* <pre> | ||
* FileSize maxFileSizeUncompressed = new FileSize("20MB"); | ||
* long maxEntries = 100; | ||
* long maxDirectoryDepth = 5; | ||
* Duration timeout = Duration.ofMinutes(1); | ||
* | ||
* ArchiveExtractionConstraints properties = new ArchiveExtractionConstraints(maxFileSizeUncompressed, maxEntries, maxDirectoryDepth, timeout); | ||
* </pre> | ||
* | ||
* @author hamidonos | ||
*/ | ||
public class ArchiveExtractionConstraints { | ||
private final FileSize maxFileSizeUncompressed; | ||
private final long maxEntries; | ||
private final long maxDirectoryDepth; | ||
private final Duration timeout; | ||
|
||
public ArchiveExtractionConstraints(FileSize maxFileSizeUncompressed, long maxEntries, long maxDirectoryDepth, Duration timeout) { | ||
this.maxFileSizeUncompressed = requireNonNull(maxFileSizeUncompressed, "Property maxFileSizeUncompressed must not be null"); | ||
this.maxEntries = maxEntries; | ||
if (this.maxEntries <= 0) { | ||
throw new IllegalArgumentException("Property maxEntries must be greater than 0"); | ||
} | ||
this.maxDirectoryDepth = maxDirectoryDepth; | ||
if (this.maxDirectoryDepth <= 0) { | ||
throw new IllegalArgumentException("Property maxDirectoryDepth must be greater than 0"); | ||
} | ||
this.timeout = requireNonNull(timeout, "Property timeout must not be null"); | ||
if (this.timeout.isNegative() || this.timeout.isZero()) { | ||
throw new IllegalArgumentException("Property timeout must be greater than 0"); | ||
} | ||
} | ||
|
||
public FileSize getMaxFileSizeUncompressed() { | ||
return maxFileSizeUncompressed; | ||
} | ||
|
||
public long getMaxEntries() { | ||
return maxEntries; | ||
} | ||
|
||
public long getMaxDirectoryDepth() { | ||
return maxDirectoryDepth; | ||
} | ||
|
||
public Duration getTimeout() { | ||
return timeout; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (!(o instanceof ArchiveExtractionConstraints that)) { | ||
return false; | ||
} | ||
return Objects.equals(maxFileSizeUncompressed, that.maxFileSizeUncompressed) && Objects.equals(maxEntries, that.maxEntries) | ||
&& Objects.equals(maxDirectoryDepth, that.maxDirectoryDepth) && Objects.equals(timeout, that.timeout); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(maxFileSizeUncompressed, maxEntries, maxDirectoryDepth, timeout); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ive/src/main/java/com/mercedesbenz/sechub/commons/archive/ArchiveExtractionException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.commons.archive; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* This exception is thrown when an error occurs during extraction of an archive | ||
* through the {@link SafeArchiveInputStream}. | ||
* | ||
* @author hamidonos | ||
*/ | ||
public class ArchiveExtractionException extends IOException { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public ArchiveExtractionException(String msg) { | ||
super(msg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.