|
| 1 | +# Twyn Action |
| 2 | + |
| 3 | +A GitHub Action that runs security checks against dependency typosquatting attacks using [Twyn](https://github.com/elementsinteractive/twyn). |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +## What is Twyn? |
| 9 | + |
| 10 | +Twyn is a security tool that analyzes your project dependencies to detect potential typosquatting attacks - when malicious packages have names similar to legitimate ones to trick developers into installing them. |
| 11 | + |
| 12 | +## Examples |
| 13 | + |
| 14 | +### Basic Security Check |
| 15 | + |
| 16 | +```yaml |
| 17 | +- name: Run Twyn Security Check |
| 18 | + uses: elementsinteractive/twyn-action@v1 |
| 19 | +``` |
| 20 | +
|
| 21 | +### With Table Output and PR Comments |
| 22 | +
|
| 23 | +```yaml |
| 24 | +- name: Run Twyn Security Check |
| 25 | + uses: elementsinteractive/twyn-action@v1 |
| 26 | + with: |
| 27 | + table: true |
| 28 | + version: v6 |
| 29 | + publish: true |
| 30 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 31 | +``` |
| 32 | +
|
| 33 | +### Analyze Specific Files |
| 34 | +
|
| 35 | +```yaml |
| 36 | +- name: Run Twyn Security Check |
| 37 | + uses: elementsinteractive/twyn-action@v1 |
| 38 | + with: |
| 39 | + dependency-file: "requirements.txt,package.json" |
| 40 | + table: true |
| 41 | + recursive: true |
| 42 | +``` |
| 43 | +
|
| 44 | +
|
| 45 | +## Inputs |
| 46 | +
|
| 47 | +| Input | Description | Required | Default | |
| 48 | +|-------|-------------|----------|---------| |
| 49 | +| `dependency-file` | Dependency file(s) to analyze (comma-separated) | No | Auto-detect | |
| 50 | +| `table` | Display results in table format (requires version >=v6) | No | `false` | |
| 51 | +| `json` | Display results in JSON format | No | `false` | |
| 52 | +| `publish` | Publish results as PR comments | No | `false` | |
| 53 | +| `github-token` | GitHub token for publishing comments | No | - | |
| 54 | +| `recursive` | Recursively search for dependency files | No | `false` | |
| 55 | +| `selector-method` | Method for selecting typosquats (`first-letter`, `nearby-letter`, `all`) | No | - | |
| 56 | +| `v` | Enable verbose output | No | `false` | |
| 57 | +| `vv` | Enable extra verbose output | No | `false` | |
| 58 | +| `version` | Twyn version to use | No | `latest` | |
| 59 | + |
| 60 | +## Outputs |
| 61 | + |
| 62 | +| Output | Description | |
| 63 | +|--------|-------------| |
| 64 | +| `results` | Raw output from twyn scan | |
| 65 | +| `exit-code` | Exit code (0=no issues, 1=issues found, >1=error) | |
| 66 | +| `has-findings` | Boolean indicating if issues were found | |
| 67 | + |
| 68 | +## Publishing Results to PR |
| 69 | + |
| 70 | +When `publish: true` is enabled, the action will automatically post a comment to the Pull Request with a formatted table showing any security findings. This requires: |
| 71 | +- `table: true` (automatically enabled when publish is true) |
| 72 | +- `version: "v6"` or higher (table format requires Twyn v6+) |
| 73 | +- `github-token` to be provided |
| 74 | +- The workflow to run on a Pull Request event |
| 75 | + |
| 76 | +The PR comment will include a detailed table with information about potential typosquatting packages found. |
| 77 | + |
0 commit comments