Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-dunn-sublime committed Oct 25, 2023
1 parent 3b36565 commit 6cc418d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/rule-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ jobs:
- name: Get base ref
id: get_base_ref
run: |
if [ ${{ github.event_name }} == 'pull_request_target' ]; then
if [[ "${{ github.event_name }}" == 'pull_request_target' ]]; then
# Detect changes based on whatever we're merging into.
echo "##[set-output name=ref;]${{ github.base_ref }}"
elif [ ${{ github.event_name }} == 'push' ]; then
elif [[ "${{ github.event_name }}" == 'push' ]]; then
# Detect changes based on the previous commit
echo "##[set-output name=ref;]$(git rev-parse HEAD^)"
elif [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
elif [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
# Run on a target, so run for all rules.
echo "##[set-output name=run_all;]true"
fi
Expand Down Expand Up @@ -141,25 +141,24 @@ jobs:
for file in detection-rules/*.yml; do
rule_id=$(yq '.id' $file)
if [ ${{ steps.get_base_ref.outputs.run_all }} = 'true' ]; then
if [[ "${{ steps.get_base_ref.outputs.run_all }}" == "true" ]]; then
altered_rule_ids=$(echo "$rule_id"" ""$altered_rule_ids")
continue
fi
echo "$file has rule ID $rule_id"
new_source=$(yq '.source' "$file")
old_source=$(yq '.source' "sr-main/detection-rules/$rule_id.yml" || echo '')
# We only need to care when rule source is changed. This will handle renames, tag changes, etc.
if [ "$new_source" != "$old_source" ]; then
echo "$file has altered source"
if [[ "$new_source" != "$old_source" ]]; then
echo "$file ($rule_id) has altered source"
altered_rule_ids=$(echo "$rule_id"" ""$altered_rule_ids")
fi
done
for file in ${{ steps.changed-files.outputs.deleted_files }}; do
rule_id=$(yq '.id' $file)
echo "$file has rule ID $rule_id and was deleted"
echo "$file ($rule_id) was deleted"
altered_rule_ids=$(echo "$rule_id"" ""$altered_rule_ids")
done
Expand Down

0 comments on commit 6cc418d

Please sign in to comment.