Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/check-license-headers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: Check License Headers

on:
pull_request:
push:
branches: [main]
workflow_dispatch:

jobs:
check-license:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Check license headers
run: |
echo "Checking for required license headers..."

# Define the required headers for different file types
HEADER_HASH="# Copyright (c) Microsoft Corporation."
HEADER_SLASH="// Copyright (c) Microsoft Corporation."

# Find files that should have headers
files_to_check=$(find . -type f \( \
-name "*.cs" -o \
-name "*.ts" -o \
-name "*.js" -o \
-name "*.sh" -o \
-name "*.yml" -o \
-name "*.yaml" \
\) \
-not -path "./.git/*" \
-not -path "./node_modules/*" \
-not -path "./**/bin/*" \
-not -path "./**/obj/*")

missing_headers=()

for file in $files_to_check; do
echo "Checking: $file"

# Check based on file extension
case "$file" in
*.sh|*.yml|*.yaml)
if ! head -5 "$file" | grep -q "# Copyright (c) Microsoft Corporation."; then
missing_headers+=("$file")
fi
;;
*.cs|*.ts|*.js)
if ! head -5 "$file" | grep -q "// Copyright (c) Microsoft Corporation."; then
missing_headers+=("$file")
fi
;;
esac
done

# Report results
if [ ${#missing_headers[@]} -eq 0 ]; then
echo "✅ All files have required license headers"
else
echo "❌ The following files are missing license headers:"
printf '%s\n' "${missing_headers[@]}"
echo ""
echo "Please add the appropriate header to each file:"
echo "For .sh/.yml/.yaml files:"
echo " # Copyright (c) Microsoft Corporation."
echo " # Licensed under the MIT License."
echo ""
echo "For .cs/.ts/.js files:"
echo " // Copyright (c) Microsoft Corporation."
echo " // Licensed under the MIT License."
exit 1
fi
55 changes: 55 additions & 0 deletions .github/workflows/update-ip-ranges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: Verify IP Address Ranges

on:
pull_request:
paths:
- 'config/IPAddressRanges.json'
- 'nodejs/config/IPAddressRanges.ts'
- 'csharp/config/IPAddressRanges.cs'
push:
branches: [main]
paths:
- 'config/IPAddressRanges.json'
- 'nodejs/config/IPAddressRanges.ts'
- 'csharp/config/IPAddressRanges.cs'
workflow_dispatch: # Allow manual triggering

jobs:
verify-ranges:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Make scripts executable
run: chmod +x scripts/*.sh

- name: Build Node.js/TypeScript version
run: ./scripts/build-ip-ranges-nodejs.sh

- name: Build C# version
run: ./scripts/build-ip-ranges-cs.sh

- name: Verify generated files are up-to-date
run: |
if ! git diff --exit-code nodejs/config/IPAddressRanges.ts csharp/config/IPAddressRanges.cs; then
echo "❌ Generated IP address range files are out of sync!"
echo "The following files need to be regenerated:"
git diff --name-only nodejs/config/IPAddressRanges.ts csharp/config/IPAddressRanges.cs
echo ""
echo "Please run the following commands locally and commit the results:"
echo " ./scripts/build-ip-ranges-nodejs.sh"
echo " ./scripts/build-ip-ranges-cs.sh"
exit 1
else
echo "✅ All generated files are up-to-date"
fi
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,5 @@ FodyWeavers.xsd
*.msix
*.msm
*.msp

.DS_Store
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing to AntiSSRF

Thank you for your interest in contributing to the AntiSSRF project! This guide will help you get started.

## Development Setup

1. Clone the repository
2. Install dependencies for your target language (C# or Node.js)
3. Make your changes
4. Test thoroughly
5. Submit a pull request

## Updating IP Address Ranges

The IP address ranges are maintained in [`config/IPAddressRanges.json`](config/IPAddressRanges.json) and automatically generated into language-specific files.

### Prerequisites
Install `jq`: `brew install jq` (macOS) or `sudo apt-get install jq` (Linux)

### Process
1. **Edit** [`config/IPAddressRanges.json`](config/IPAddressRanges.json)
2. **Regenerate** the code files:
```bash
./scripts/build-ip-ranges-nodejs.sh
./scripts/build-ip-ranges-cs.sh
```
3. **Commit** all changes (JSON + generated files):
```bash
git add config/IPAddressRanges.json nodejs/config/IPAddressRanges.ts csharp/config/IPAddressRanges.cs
git commit -m "Update IP address ranges"
```

**Important**: The GitHub Actions workflow will fail if generated files don't match the source JSON.
Loading