|
| 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 | + pull_request: |
| 18 | + branches: [ main ] |
| 19 | + |
| 20 | +- name: Run Twyn Security Check |
| 21 | + uses: elementsinteractive/twyn-action@v1 |
| 22 | + with: |
| 23 | + publish: true |
| 24 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 25 | +``` |
| 26 | +
|
| 27 | +## Inputs |
| 28 | +
|
| 29 | +| Input | Description | Required | Default | |
| 30 | +|-------|-------------|----------|---------| |
| 31 | +| `dependency-file` | Dependency file(s) to analyze (comma-separated) | No | Auto-detect | |
| 32 | +| `table` | Display results in table format (requires version >=v6) | No | `false` | |
| 33 | +| `json` | Display results in JSON format | No | `false` | |
| 34 | +| `publish` | Publish results as PR comments. It must run in a PR context | No | `false` | |
| 35 | +| `github-token` | GitHub token for publishing comments | No | - | |
| 36 | +| `recursive` | Recursively search for dependency files | No | `false` | |
| 37 | +| `selector-method` | Method for selecting typosquats (`first-letter`, `nearby-letter`, `all`) | No | - | |
| 38 | +| `v` | Enable verbose output | No | `false` | |
| 39 | +| `vv` | Enable extra verbose output | No | `false` | |
| 40 | +| `version` | Twyn version to use | No | `latest` | |
| 41 | + |
| 42 | +## Outputs |
| 43 | + |
| 44 | +| Output | Description | |
| 45 | +|--------|-------------| |
| 46 | +| `results` | Raw output from twyn scan | |
| 47 | +| `exit-code` | Exit code (0=no issues, 1=issues found, >1=error) | |
| 48 | +| `has-findings` | Boolean indicating if issues were found | |
| 49 | + |
| 50 | +## Publishing Results to PR |
| 51 | + |
| 52 | +When `publish: true` is enabled, the action will automatically post a comment to the Pull Request with a formatted table showing any security findings. |
| 53 | + |
| 54 | +**⚠️ Important: Publishing only works when the workflow runs in a Pull Request context.** Make sure your workflow is triggered by `pull_request` events, not just `push` or `workflow_dispatch`. |
| 55 | + |
| 56 | +This requires: |
| 57 | +- `table: true` (automatically enabled when publish is true) |
| 58 | +- `version: "v6"` or higher (table format requires Twyn v6+) |
| 59 | +- `github-token` to be provided |
| 60 | +- The workflow to run on a Pull Request event (`on: pull_request`) |
| 61 | + |
| 62 | +The PR comment will include a detailed table with information about potential typosquatting packages found. |
0 commit comments