Skip to content

Commit

Permalink
Add json support + improve logs + fix directory scan
Browse files Browse the repository at this point in the history
  • Loading branch information
serresebastien committed Oct 12, 2023
1 parent 91883f5 commit 5c0b89e
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,31 @@ fi
# Create an empty array to store file names to scan
RESOURCES_TO_SCAN=()

# If File Variable exists then scan the specific resource
# If INPUT_FILE variable exists then scan the specific resource
if [ -n "$INPUT_FILE" ]; then
RESOURCES_TO_SCAN+=("$INPUT_FILE")
else
# Otherwise scan directory provided (root by default) to populate the array with all .yml or .yaml files
echo "running susscanner on directory: $INPUT_DIRECTORY"
for FILE in "$INPUT_DIRECTORY"/*.yaml "$INPUT_DIRECTORY"/*.yml; do
RESOURCES_TO_SCAN+=("$FILE")
done
# Otherwise scan directory provided (root by default)
if [ -d "$INPUT_DIRECTORY" ]; then
# Use 'find' to search for YAML and JSON files inside the directory
while IFS= read -r -d $'\0' file; do
RESOURCES_TO_SCAN+=("$file")
done < <(find "$INPUT_DIRECTORY" -type f \( -name "*.json" -o -name "*.yaml" -o -name "*.yml" \) -print0)

# Check if any files were found
if [ -n "$RESOURCES_TO_SCAN" ]; then
echo "${#RESOURCES_TO_SCAN[@]} file(s) found in directory: $INPUT_DIRECTORY"
else
echo "No template files found in directory: $INPUT_DIRECTORY"
fi
else
echo "Directory not found: $INPUT_DIRECTORY"
fi
fi

# Build command
for RESOURCE in $RESOURCES_TO_SCAN; do
echo "running susscanner on file: $RESOURCE"
for RESOURCE in "${RESOURCES_TO_SCAN[@]}"; do
echo "Running susscanner on file: $RESOURCE"
echo "susscanner $RESOURCE $RULES_FILE"
SUSSCAN_RESULTS=$(susscanner $RESOURCE $RULES_FILE)

Expand Down

0 comments on commit 5c0b89e

Please sign in to comment.