Skip to content

Commit

Permalink
fix: Renaming test project manifest files to avoid security scanning
Browse files Browse the repository at this point in the history
Why: To prevent deprecated/vulnerable library dependencies in
sample projects from being flagged during security scanning,
as these sample projects are not intended for production use
but needed to run integration tests.

How: Renaming all manifest files
(e.g., pom.xml, package.json, requirements.txt, Gemfile)
to a placeholder name (_PLACEHOLDER) and renaming them back with
the correct name during the integration test setup.
  • Loading branch information
as14692 authored and Anushka Srinivasa committed May 6, 2024
1 parent 710b081 commit 840efd2
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ if($LASTEXITCODE -ne 0) {
throw "*ERROR**: failed to initialize Python Virtual Environment"
}

# Rename all project manifests to correct format.
# This is done to avoid security scanning them for deprecated/vulnerable library dependencies
# These sample projects are not intended to be used in production, but are used for testing
Rename-Item -Path "./sample-projects/dotnet-samples/sample_csproj_PLACEHOLDER" -NewName "sample.csproj"
Rename-Item -Path "./sample-projects/go-samples/compatible/go_mod_PLACEHOLDER" -NewName "go.mod"
Rename-Item -Path "./sample-projects/go-samples/incompatible/go_mod_PLACEHOLDER" -NewName "go.mod"
Rename-Item -Path "./sample-projects/java-samples/pom_xml_PLACEHOLDER" -NewName "pom.xml"
Rename-Item -Path "./sample-projects/node-samples/package_json_PLACEHOLDER" -NewName "package.json"
Rename-Item -Path "./sample-projects/python-samples/compatible/requirements_txt_PLACEHOLDER" -NewName "requirements.txt"
Rename-Item -Path "./sample-projects/python-samples/incompatible/requirements_txt_PLACEHOLDER" -NewName "requirements.txt"
Rename-Item -Path "./sample-projects/ruby-samples/Gemfile_PLACEHOLDER" -NewName "Gemfile"

Write-Host "🔬 Running unit tests"
.\Unit-Test.ps1
if($LASTEXITCODE -ne 0) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ if [ $? -ne 0 ]; then
echo "**ERROR**: failed to initialize Python Virtual Environment" && exit 1
fi

# Rename all project manifests to correct format.
# This is done to avoid security scanning them for deprecated/vulnerable library dependancies
# These sample projects are not intended to be used in production, but are used for testing
mv ./sample-projects/dotnet-samples/sample_csproj_PLACEHOLDER ./sample-projects/dotnet-samples/sample.csproj
mv ./sample-projects/go-samples/compatible/go_mod_PLACEHOLDER ./sample-projects/go-samples/compatible/go.mod
mv ./sample-projects/go-samples/incompatible/go_mod_PLACEHOLDER ./sample-projects/go-samples/incompatible/go.mod
mv ./sample-projects/java-samples/pom_xml_PLACEHOLDER ./sample-projects/java-samples/pom.xml
mv ./sample-projects/node-samples/package_json_PLACEHOLDER ./sample-projects/node-samples/package.json
mv ./sample-projects/python-samples/compatible/requirements_txt_PLACEHOLDER ./sample-projects/python-samples/compatible/requirements.txt
mv ./sample-projects/python-samples/incompatible/requirements_txt_PLACEHOLDER ./sample-projects/python-samples/incompatible/requirements.txt
mv ./sample-projects/ruby-samples/Gemfile_PLACEHOLDER ./sample-projects/ruby-samples/Gemfile

# run unit tests
echo "🔬 Running unit tests"
./unit-test.sh
Expand Down

0 comments on commit 840efd2

Please sign in to comment.