forked from mercedes-benz/sechub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mercedes-benz:develop' into feature-345-summary-in-reports
- Loading branch information
Showing
470 changed files
with
26,613 additions
and
3,483 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-License-Identifier: MIT | ||
name: Build SecHub GitHub Action | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
build-scan: | ||
runs-on: ubuntu-latest | ||
# Let's set the scan action folder as the working directory for all "run" steps: | ||
working-directory: ./github-actions/scan | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
# We do not define a dedicated node version here, we just use the default environment | ||
# which should be the default environment for the github actions runtime as well | ||
uses: actions/setup-node@v3 | ||
|
||
- name: Clean install | ||
run: npm ci | ||
|
||
- name: Build | ||
run: npm run build --if-present | ||
|
||
- name: Run tests | ||
run: npm test | ||
|
||
|
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
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
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,49 @@ | ||
// SPDX-License-Identifier: MIT | ||
/** | ||
* Special build stage class. Because we need compiled java code to generate our open api file, | ||
* the java api generation - which needs the open api file + a java compile - cannot happen | ||
* on same "stage". | ||
* To provide this, we have introduced the term sechub build stage - when stage "api-necessary" is | ||
* used (or no stage is set), the parts which need a generated open api file will be included | ||
* as well. | ||
*/ | ||
class BuildStage{ | ||
|
||
private static final String STAGE_ALL = "all"; | ||
private static final String STAGE_WITHOUT_API = "without-api"; | ||
private static final String STAGE_API_NECESSARY = "api-necessary"; | ||
|
||
private String stage; | ||
private boolean openApiFileMustExist; | ||
private boolean acceptAll; | ||
|
||
BuildStage(){ | ||
stage = System.getProperty("sechub.build.stage"); | ||
if(stage==null|| stage.isEmpty()){ | ||
// Per default we do not support API parts to avoid build life cycle problems | ||
stage = STAGE_WITHOUT_API; | ||
} | ||
|
||
switch(stage){ | ||
case STAGE_ALL: | ||
// We just do not define any constraints here | ||
// Meaning: this stage can be imported by IDEs | ||
acceptAll=true; | ||
break; | ||
case STAGE_WITHOUT_API: | ||
openApiFileMustExist=false; | ||
break; | ||
case STAGE_API_NECESSARY: | ||
openApiFileMustExist=true; | ||
break; | ||
default: | ||
throw new IllegalArgumentException("Unknown build stage: '"+ stage+"'"); | ||
} | ||
|
||
} | ||
|
||
public boolean providesGeneratedOpenApiFile(){ | ||
return acceptAll || openApiFileMustExist; | ||
} | ||
|
||
} |
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,63 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.nio.file.Path; | ||
import java.nio.file.StandardCopyOption; | ||
import java.io.IOException; | ||
|
||
public class IOUtil { | ||
|
||
/** | ||
* Creates a backup copy for the given file (if the file does exist) which | ||
* can be restored by IOUtil. The location of the backup is handled by IOUtil internally. | ||
* | ||
* @param filePath the path for the file to backup | ||
* @param backupPostFix a special post fix for the backup file, the backup file has | ||
* the same name as the origin one, but with the post fix. | ||
*/ | ||
public static final void createBackupFile(String filePath, String backupPostFix) throws IOException{ | ||
Path sourcePath = Paths.get(filePath); | ||
Path targetPath = Paths.get(filePath + "_" + backupPostFix); | ||
|
||
if (!Files.exists(sourcePath)) { | ||
return; | ||
} | ||
System.out.println("Create backup file: "+targetPath + "\nfrom: "+sourcePath); | ||
|
||
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
|
||
/** | ||
* Restores a previously created backup to the wanted file path (if a backup exists). | ||
* The location of the backup is handled by IOUtil internally. | ||
* | ||
* @param filePath the path for the file to restore (not the backup file!) | ||
* @backupPostFix a special post fix for the backup file | ||
*/ | ||
public static final void restoreBackupFile(String filePath, String backupPostFix) throws IOException{ | ||
Path targetPath = Paths.get(filePath); | ||
Path sourcePath = Paths.get(filePath + "_" + backupPostFix); | ||
if (!Files.exists(sourcePath)) { | ||
return; | ||
} | ||
System.out.println("Restore: "+targetPath + "\nfrom backup file: "+sourcePath); | ||
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
|
||
/** | ||
* Copy a file to another location | ||
* @sourcePath source path as string | ||
* @targetPath target path as string | ||
*/ | ||
public static final void copyFile(String sourcePath, String targetPath) throws IOException{ | ||
|
||
Path source = Paths.get(sourcePath); | ||
Path target = Paths.get(targetPath); | ||
|
||
target.toFile().getParentFile().mkdirs(); | ||
|
||
System.out.println("Copy: "+source + "\nto : "+target); | ||
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); | ||
} | ||
} |
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.