Skip to content
Back to search

opentaint

MarketplaceWorks with Claude CodeGitHub

OpenTaint skills extend built-in security rules and code models for your dependencies and frameworks, then find vulnerabilities with whole-program static taint analysis

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/seqra/opentaint with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/seqra/opentaint'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/seqra--opentaint/badge.svg)](/listings/seqra--opentaint)

HTML

<a href="/listings/seqra--opentaint"><img src="/api/listings/seqra--opentaint/badge.svg" alt="findsafeskills safety rating" /></a>

Install

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

These steps run a script from the network that findsafeskills does not scan.

**Install script (Linux/macOS)**

curl -fsSL https://opentaint.org/install.sh | bash

**Install via Homebrew (Linux/macOS):**

brew install --cask seqra/tap/opentaint

**Install script (Windows PowerShell)**

irm https://opentaint.org/install.ps1 | iex

**Install via npm (Linux/macOS/Windows):**

npm install -g @seqra/opentaint

**Or run instantly with npx — no install required (needs Node.js):**

npx @seqra/opentaint scan

**Scan your project:**

opentaint scan

**Or use Docker:**

docker run --rm -v $(pwd):/project -v $(pwd):/output \
  ghcr.io/seqra/opentaint:latest \
  opentaint scan --output /output/results.sarif /project

For more options, see [Installation](docs/README.md#installation) and [Usage](docs/README.md#usage).

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/marketplace.json · Manifest · 24 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. {
  2. "$schema": "https://anthropic.com/claude-code/marketplace.schema.json",
  3. "name": "opentaint",
  4. "description": "OpenTaint skills extend built-in security rules and code models for your dependencies and frameworks, then find vulnerabilities with whole-program static taint analysis",
  5. "owner": {
  6. "name": "Seqra",
  7. "url": "https://opentaint.org/"
  8. },
  9. "plugins": [
  10. {
  11. "name": "appsec-workflow",
  12. "source": "./",
  13. "description": "Find application-specific vulnerabilities with whole-program static taint analysis and write rules and dependency models for future scans",
  14. "version": "0.3.0",
  15. "author": {
  16. "name": "Seqra"
  17. },
  18. "license": "Apache-2.0",
  19. "category": "security",
  20. "homepage": "https://opentaint.org/",
  21. "repository": "https://github.com/seqra/opentaint"
  22. }
  23. ]
  24. }
README.md · README · 223 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. <p align="center">
  2. <picture>
  3. <source media="(prefers-color-scheme: dark)" srcset="logos/opentaint-logo-dark.svg">
  4. <source media="(prefers-color-scheme: light)" srcset="logos/opentaint-logo-light.svg">
  5. <img src="logos/opentaint-logo-light.svg" alt="OpenTaint" height="100">
  6. </picture>
  7. </p>
  8. <h3 align="center">The open source taint analysis engine for the AI era</h3>
  9. <p align="center">
  10. Formal taint analysis for application security — finds what AST-pattern matchers miss, lets LLM agents enact rules from vulnerabilities, scales where neither can alone.
  11. </p>
  12. <p align="center">
  13. <a href="https://github.com/seqra/opentaint/releases"><img src="https://img.shields.io/github/release/seqra/opentaint.svg" alt="GitHub release"></a>
  14. <a href="LICENSE.md"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0"></a>
  15. <a href="https://golang.org/"><img src="https://img.shields.io/badge/Go-1.25+-00ADD8?logo=go" alt="Go Version"></a>
  16. <a href="https://discord.gg/6BXDfbP4p9"><img src="https://img.shields.io/discord/1403357427176575036?logo=discord&label=Discord" alt="Discord"></a>
  17. </p>
  18. <p align="center">
  19. <a href="README.md">English</a> | <a href="docs/translations/README.zh.md">简体中文</a> | <a href="docs/translations/README.zht.md">繁體中文</a> | <a href="docs/translations/README.ko.md">한국어</a> | <a href="docs/translations/README.de.md">Deutsch</a> | <a href="docs/translations/README.es.md">Español</a> | <a href="docs/translations/README.fr.md">Français</a> | <a href="docs/translations/README.it.md">Italiano</a> | <a href="docs/translations/README.da.md">Dansk</a> | <a href="docs/translations/README.ja.md">日本語</a> | <a href="docs/translations/README.pl.md">Polski</a> | <a href="docs/translations/README.ru.md">Русский</a> | <a href="docs/translations/README.bs.md">Bosanski</a> | <a href="docs/translations/README.ar.md">العربية</a> | <a href="docs/translations/README.no.md">Norsk</a> | <a href="docs/translations/README.sv.md">Svenska</a> | <a href="docs/translations/README.br.md">Português (Brasil)</a> | <a href="docs/translations/README.th.md">ไทย</a> | <a href="docs/translations/README.tr.md">Türkçe</a> | <a href="docs/translations/README.ua.md">Українська</a> | <a href="docs/translations/README.bn.md">বাংলা</a> | <a href="docs/translations/README.hi.md">हिन्दी</a> | <a href="docs/translations/README.gr.md">Ελληνικά</a> | <a href="docs/translations/README.vi.md">Tiếng Việt</a> | <a href="docs/translations/README.id.md">Bahasa Indonesia</a>
  20. </p>
  21. <p align="center">
  22. <a href="http://opentaint.org/">
  23. <picture>
  24. <source media="(prefers-color-scheme: dark)" srcset="public/opentaint-demo-dark.gif">
  25. <source media="(prefers-color-scheme: light)" srcset="public/opentaint-demo-light.gif">
  26. <img src="public/opentaint-demo-light.gif" alt="OpenTaint taint analysis demo">
  27. </picture>
  28. </a>
  29. </p>
  30. <p align="center"><b>Supported technologies and integrations</b></p>
  31. <p align="center">
  32. <img src="logos/java-logo.svg" alt="Java" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  33. <img src="logos/kotlin-logo.svg" alt="Kotlin" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  34. <img src="logos/spring-boot-logo.svg" alt="Spring" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  35. <picture>
  36. <source media="(prefers-color-scheme: dark)" srcset="logos/github-logo-dark.svg">
  37. <source media="(prefers-color-scheme: light)" srcset="logos/github-logo-light.svg">
  38. <img src="logos/github-logo-light.svg" alt="GitHub" height="60">
  39. </picture>&nbsp;&nbsp;&nbsp;&nbsp;
  40. <img src="logos/gitlab-logo.svg" alt="GitLab" height="60">
  41. </p>
  42. <p align="center"><i>The most thorough taint analysis engine for Spring apps</i></p>
  43. <p align="center"><b>Roadmap</b></p>
  44. <p align="center">
  45. <img src="logos/python-logo.svg" alt="Python" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  46. <img src="logos/go-logo.svg" alt="Go" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  47. <img src="logos/csharp-logo.svg" alt="C#" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  48. <img src="logos/javascript-logo.svg" alt="JavaScript" height="60">&nbsp;&nbsp;&nbsp;&nbsp;
  49. <img src="logos/typescript-logo.svg" alt="TypeScript" height="60">
  50. </p>
  51. <div align="center">
  52. <details>
  53. <summary><b>More screenshots</b></summary>
  54. <p align="center">
  55. <picture>
  56. <source media="(prefers-color-scheme: dark)" srcset="public/opentaint-frame-dark-1.png">
  57. <source media="(prefers-color-scheme: light)" srcset="public/opentaint-frame-light-1.png">
  58. <img src="public/opentaint-frame-light-1.png" alt="OpenTaint scan output">
  59. </picture>
  60. </p>
  61. <p align="center">
  62. <picture>
  63. <source media="(prefers-color-scheme: dark)" srcset="public/opentaint-frame-dark-2.png">
  64. <source media="(prefers-color-scheme: light)" srcset="public/opentaint-frame-light-2.png">
  65. <img src="public/opentaint-frame-light-2.png" alt="OpenTaint summary output">
  66. </picture>
  67. </p>
  68. <p align="center">
  69. <picture>
  70. <source media="(prefers-color-scheme: dark)" srcset="public/opentaint-frame-dark-3.png">
  71. <source media="(prefers-color-scheme: light)" srcset="public/opentaint-frame-light-3.png">
  72. <img src="public/opentaint-frame-light-3.png" alt="OpenTaint summary output">
  73. </picture>
  74. </p>
  75. <p align="center">
  76. <picture>
  77. <source media="(prefers-color-scheme: dark)" srcset="public/opentaint-frame-dark-4.png">
  78. <source media="(prefers-color-scheme: light)" srcset="public/opentaint-frame-light-4.png">
  79. <img src="public/opentaint-frame-light-4.png" alt="OpenTaint summary output">
  80. </picture>
  81. </p>
  82. <p align="center">
  83. <picture>
  84. <source media="(prefers-color-scheme: dark)" srcset="public/opentaint-frame-dark-5.png">
  85. <source media="(prefers-color-scheme: light)" srcset="public/opentaint-frame-light-5.png">
  86. <img src="public/opentaint-frame-light-5.png" alt="OpenTaint summary output">
  87. </picture>
  88. </p>
  89. </details>
  90. </div>
  91. ---
  92. ## Why OpenTaint?
  93. > OpenTaint is an open-source alternative to *Semgrep Pro* and *CodeQL* — a formal inter-procedural taint engine you can customize and self-host, built so AI agents drive your security analysis without burning tokens on every scan.
  94. AI generates production code faster than security teams can keep up with, and the two kinds of tooling built to catch what it gets wrong each force a bad trade-off:
  95. - **AST-pattern matchers** (Semgrep OSS, ast-grep, linters) are free and fast, but they match syntax, not data flow — untrusted input that crosses a function boundary or a persistence layer slips right past. The deeper, inter-procedural analysis that *does* catch it has long been locked inside proprietary tools.
  96. - **LLM security agents** find what pattern matchers miss, but they re-read your code on every run. The tokens add up with every file, every commit, every CI build — and a probabilistic model still can't promise it caught everything.
  97. OpenTaint gives you the depth of an LLM agent at the cost of a static analyzer:
  98. - **Find what AST-pattern matchers miss.** A formal inter-procedural dataflow engine tracks untrusted data across function boundaries, persistence layers, aliases, and async code.
  99. - **Pay the model once, not on every scan.** Let an agent distill a single finding into a taint rule. The deterministic engine then replays that rule across the entire codebase — and every commit after it — in minutes of CPU, at zero token cost.
  100. - **Open source, batteries included.** Engine, rules, and CI integrations come as one stack under Apache 2.0 and MIT.
  101. ## Quick Start
  102. **Install script (Linux/macOS)**
  103. ```
  104. curl -fsSL https://opentaint.org/install.sh | bash
  105. ```
  106. **Install via Homebrew (Linux/macOS):**
  107. ```bash
  108. brew install --cask seqra/tap/opentaint
  109. ```
  110. **Install script (Windows PowerShell)**
  111. ```
  112. irm https://opentaint.org/install.ps1 | iex
  113. ```
  114. **Install via npm (Linux/macOS/Windows):**
  115. ```bash
  116. npm install -g @seqra/opentaint
  117. ```
  118. **Or run instantly with npx — no install required (needs Node.js):**
  119. ```bash
  120. npx @seqra/opentaint scan
  121. ```
  122. **Scan your project:**
  123. ```bash
  124. opentaint scan
  125. ```
  126. **Or use Docker:**
  127. ```bash
  128. docker run --rm -v $(pwd):/project -v $(pwd):/output \
  129. ghcr.io/seqra/opentaint:latest \
  130. opentaint scan --output /output/results.sarif /project
  131. ```
  132. For more options, see [Installation](docs/README.md#installation) and [Usage](docs/README.md#usage).
  133. ---
  134. ## AI Agent Workflows
  135. OpenTaint includes agent skills that turn static analysis into an end-to-end application-security workflow.
  136. <details>
  137. <summary><strong>Install for Codex</strong></summary>
  138. ```bash
  139. codex plugin marketplace add seqra/opentaint
  140. codex plugin add appsec-workflow@opentaint
  141. ```
  142. </details>
  143. <details>
  144. <summary><strong>Install for Claude Code</strong></summary>
  145. ```bash
  146. claude plugin marketplace add seqra/opentaint
  147. claude plugin install appsec-workflow@opentaint
  148. ```
  149. </details>
  150. Or install the skills directly for any supported agent:
  151. ```bash
  152. npx skills add https://github.com/seqra/opentaint
  153. ```
  154. The `appsec-agent` skill orchestrates a full project assessment: build the project, run OpenTaint, discover the attack surface, add targeted rules, model missing library data flows, triage findings, and optionally generate dynamic proof-of-concept checks for confirmed vulnerabilities.
  155. Included skills cover the common security-analysis loop:
  156. - **Scan and triage:** `build-project`, `run-scan`, `analyze-findings`, `generate-poc`
  157. - **Coverage expansion:** `triage-dependencies`, `discover-attack-surface`, `create-test-project`, `create-rule`, `assemble-lib-rules`
  158. - **Dataflow modeling:** `analyze-external-methods`, `create-pass-through-model`, `create-dataflow-model`, `debug-rule`, `report-analyzer-issue`
  159. ---
  160. ## Documentation
  161. Full guides — installation, usage, configuration, CI/CD integration: **[Documentation](docs/README.md)**.
  162. ## Support
  163. - **Issues:** [GitHub Issues](https://github.com/seqra/opentaint/issues)
  164. - **Community:** [Discord](https://discord.gg/6BXDfbP4p9)
  165. - **Email:** [seqradev@gmail.com](mailto:seqradev@gmail.com)
  166. ## Star History
  167. <a href="https://github.com/seqra/opentaint/stargazers">
  168. <picture>
  169. <source media="(prefers-color-scheme: dark)" srcset="https://github.com/seqra/opentaint/releases/download/star-history/latest/star-history-dark.png" />
  170. <source media="(prefers-color-scheme: light)" srcset="https://github.com/seqra/opentaint/releases/download/star-history/latest/star-history-light.png" />
  171. <img alt="Star History Chart" src="https://github.com/seqra/opentaint/releases/download/star-history/latest/star-history-light.png" width="900" />
  172. </picture>
  173. </a>
  174. ## License
  175. The [core analysis engine](core/) is released under the [Apache 2.0 License](LICENSE.md). The [CLI](cli/), [GitHub Action](github/), [GitLab CI template](gitlab/), and [rules](rules/) are released under the [MIT License](cli/LICENSE).
scripts/install/install.ps1 · Bundled script · 266 lines · 1 finding marked
  1. # OpenTaint installer for Windows (PowerShell)
  2. # Usage:
  3. # irm https://raw.githubusercontent.com/seqra/opentaint/main/scripts/install/install.ps1 | iex
    • Note: Runs a downloaded PowerShell script (iex / Invoke-Expression)
    • Line 3 on GitHub
  4. # & ([scriptblock]::Create((irm .../install.ps1))) -Version v0.4.5 # exact version ('v' optional)
  5. # & ([scriptblock]::Create((irm .../install.ps1))) -Version v0 # newest v0.x.y
  6. # & ([scriptblock]::Create((irm .../install.ps1))) -Version v0.4 # newest v0.4.x
  7. param(
  8. [string]$Version = "latest"
  9. )
  10. $ErrorActionPreference = 'Stop'
  11. $Repo = if ($env:OPENTAINT_REPOSITORY) { $env:OPENTAINT_REPOSITORY } else { "seqra/opentaint" }
  12. # Resolves a floating major/minor selector (e.g. v0 or v0.2) to the newest
  13. # matching exact vX.Y.Z release tag via the GitHub releases API. Only exact
  14. # vX.Y.Z tags are considered, mirroring scripts/resolve_opentaint_version.py.
  15. function Resolve-FloatingSelector {
  16. param(
  17. [string]$Selector # e.g. v0 or v0.2
  18. )
  19. $headers = @{ "Accept" = "application/vnd.github+json" }
  20. $token = if ($env:OPENTAINT_GITHUB_TOKEN) { $env:OPENTAINT_GITHUB_TOKEN } elseif ($env:GITHUB_TOKEN) { $env:GITHUB_TOKEN } else { $null }
  21. if ($token) { $headers["Authorization"] = "Bearer $token" }
  22. $releases = @()
  23. $page = 1
  24. while ($true) {
  25. $apiUrl = "https://api.github.com/repos/$Repo/releases?per_page=100&page=$page"
  26. try {
  27. $pageReleases = @(Invoke-RestMethod -Uri $apiUrl -Headers $headers -UseBasicParsing)
  28. } catch {
  29. [Console]::Error.WriteLine("Error: failed to query the GitHub releases API to resolve '$Selector'.")
  30. exit 2
  31. }
  32. $releases += $pageReleases
  33. if ($pageReleases.Count -lt 100) { break }
  34. $page++
  35. }
  36. # v0 must match v0.*, not v0.* only after a dot boundary; the trailing dot
  37. # ensures v1 does not match v10.x and v0.1 does not match v0.10.x.
  38. $prefix = "$Selector."
  39. $best = $null
  40. foreach ($release in $releases) {
  41. $tag = $release.tag_name
  42. if ($tag -notmatch '^v[0-9]+\.[0-9]+\.[0-9]+$') { continue }
  43. if (-not $tag.StartsWith($prefix)) { continue }
  44. $ver = [version]($tag.Substring(1))
  45. if (-not $best -or $ver -gt $best.Ver) {
  46. $best = @{ Ver = $ver; Tag = $tag }
  47. }
  48. }
  49. if (-not $best) {
  50. [Console]::Error.WriteLine("Error: no release found matching selector '$Selector'.")
  51. exit 2
  52. }
  53. return $best.Tag
  54. }
  55. function Test-Version {
  56. param([string]$Raw)
  57. if (-not $Raw -or $Raw -eq "latest") {
  58. return @{ PathSegment = "latest/download"; Tag = "latest" }
  59. }
  60. if ($Raw -match '^(v)?(?<ver>[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?)$') {
  61. $normalized = $Matches['ver']
  62. return @{ PathSegment = "download/v$normalized"; Tag = "v$normalized" }
  63. }
  64. if ($Raw -match '^(v)?(?<ver>[0-9]+\.[0-9]+)$') {
  65. $selector = "v$($Matches['ver'])"
  66. Write-Host "Resolving $selector to an exact release..."
  67. $tag = Resolve-FloatingSelector -Selector $selector
  68. return @{ PathSegment = "download/$tag"; Tag = $tag }
  69. }
  70. if ($Raw -match '^(v)?(?<ver>[0-9]+)$') {
  71. $selector = "v$($Matches['ver'])"
  72. Write-Host "Resolving $selector to an exact release..."
  73. $tag = Resolve-FloatingSelector -Selector $selector
  74. return @{ PathSegment = "download/$tag"; Tag = $tag }
  75. }
  76. [Console]::Error.WriteLine("Error: Invalid version '$Raw'. Expected 'latest', 'X', 'X.Y', or 'X.Y.Z' (optionally prefixed with 'v').")
  77. exit 2
  78. }
  79. function Test-HomebrewInstall {
  80. $cmd = Get-Command opentaint -ErrorAction SilentlyContinue
  81. if (-not $cmd) {
  82. return $null
  83. }
  84. $path = $cmd.Source
  85. try {
  86. $resolved = (Resolve-Path -LiteralPath $path -ErrorAction Stop).Path
  87. $path = $resolved
  88. } catch { }
  89. # Patterns target POSIX-style Homebrew paths; meaningful only when pwsh runs
  90. # on macOS/Linux. Native Windows paths use backslashes and will not match.
  91. $lower = $path.ToLower()
  92. if ($lower -match '/cellar/' -or $lower -match '/caskroom/' -or $lower -match '/homebrew/') {
  93. return $path
  94. }
  95. return $null
  96. }
  97. function Get-Architecture {
  98. $arch = $env:PROCESSOR_ARCHITECTURE
  99. switch ($arch) {
  100. "AMD64" { return "amd64" }
  101. "ARM64" { return "arm64" }
  102. default {
  103. [Console]::Error.WriteLine("Error: Unsupported architecture: $arch")
  104. [Console]::Error.WriteLine("See https://github.com/seqra/opentaint/blob/main/docs/installation.md for alternatives.")
  105. exit 1
  106. }
  107. }
  108. }
  109. function Invoke-Download {
  110. param(
  111. [string]$Url,
  112. [string]$OutFile,
  113. [bool]$ShowProgress = $false
  114. )
  115. $previous = $ProgressPreference
  116. if (-not $ShowProgress) {
  117. $ProgressPreference = 'SilentlyContinue'
  118. }
  119. try {
  120. Invoke-WebRequest -Uri $Url -OutFile $OutFile -UseBasicParsing
  121. }
  122. finally {
  123. $ProgressPreference = $previous
  124. }
  125. }
  126. function Verify-Checksum {
  127. param(
  128. [string]$ArchivePath,
  129. [string]$ArchiveName,
  130. [string]$BaseUrl
  131. )
  132. $checksumsUrl = "$BaseUrl/checksums.txt"
  133. $checksumsFile = Join-Path ([System.IO.Path]::GetDirectoryName($ArchivePath)) "checksums.txt"
  134. Write-Host "Verifying checksum..."
  135. try {
  136. Invoke-Download -Url $checksumsUrl -OutFile $checksumsFile -ShowProgress $false
  137. } catch {
  138. Write-Warning "Could not download checksums.txt, skipping verification."
  139. return
  140. }
  141. $line = Get-Content $checksumsFile | Where-Object { $_ -match " $([regex]::Escape($ArchiveName))$" } | Select-Object -First 1
  142. if (-not $line) {
  143. Write-Warning "No checksum found for $ArchiveName, skipping verification."
  144. return
  145. }
  146. $expected = ($line -split " ")[0].ToLower()
  147. $actual = (Get-FileHash -Path $ArchivePath -Algorithm SHA256).Hash.ToLower()
  148. if ($expected -ne $actual) {
  149. [Console]::Error.WriteLine("Error: Checksum verification failed!")
  150. [Console]::Error.WriteLine(" Expected: $expected")
  151. [Console]::Error.WriteLine(" Actual: $actual")
  152. exit 1
  153. }
  154. Write-Host "Checksum verified."
  155. }
  156. function Get-InstallDir {
  157. if ($env:OPENTAINT_INSTALL_DIR) {
  158. return $env:OPENTAINT_INSTALL_DIR
  159. }
  160. return Join-Path $env:LOCALAPPDATA "opentaint"
  161. }
  162. function Main {
  163. $existingBrew = Test-HomebrewInstall
  164. if ($existingBrew -and $env:OPENTAINT_FORCE -ne "1") {
  165. [Console]::Error.WriteLine("Error: opentaint is already installed via Homebrew at $existingBrew.")
  166. [Console]::Error.WriteLine("Run 'brew upgrade --cask opentaint' to update, or set")
  167. [Console]::Error.WriteLine("`$env:OPENTAINT_FORCE='1' to install side-by-side anyway.")
  168. exit 3
  169. }
  170. $versionInfo = Test-Version -Raw $Version
  171. $baseUrl = if ($env:OPENTAINT_DOWNLOAD_BASE_URL) {
  172. $env:OPENTAINT_DOWNLOAD_BASE_URL
  173. } else {
  174. "https://github.com/$Repo/releases/$($versionInfo.PathSegment)"
  175. }
  176. $arch = Get-Architecture
  177. Write-Host "Architecture: $arch"
  178. $archiveName = "opentaint-full_windows_${arch}.zip"
  179. $url = "$baseUrl/$archiveName"
  180. $installDir = Get-InstallDir
  181. Write-Host "Install directory: $installDir"
  182. $tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) "opentaint-install-$([System.Guid]::NewGuid())"
  183. New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null
  184. try {
  185. $archivePath = Join-Path $tmpDir $archiveName
  186. Write-Host "Downloading $archiveName..."
  187. Invoke-Download -Url $url -OutFile $archivePath -ShowProgress $true
  188. Verify-Checksum -ArchivePath $archivePath -ArchiveName $archiveName -BaseUrl $baseUrl
  189. Write-Host "Extracting..."
  190. Expand-Archive -Path $archivePath -DestinationPath $tmpDir -Force
  191. Write-Host "Installing to $installDir..."
  192. New-Item -ItemType Directory -Path $installDir -Force | Out-Null
  193. $binDir = Join-Path $installDir "install"
  194. New-Item -ItemType Directory -Path $binDir -Force | Out-Null
  195. Copy-Item -Path (Join-Path $tmpDir "opentaint.exe") -Destination (Join-Path $binDir "opentaint.exe") -Force
  196. $libSrc = Join-Path $tmpDir "lib"
  197. if (Test-Path $libSrc) {
  198. $libDst = Join-Path $binDir "lib"
  199. if (Test-Path $libDst) { Remove-Item -Recurse -Force $libDst }
  200. Copy-Item -Recurse -Path $libSrc -Destination $libDst
  201. }
  202. $jreSrc = Join-Path $tmpDir "jre"
  203. if (Test-Path $jreSrc) {
  204. $jreDst = Join-Path $binDir "jre"
  205. if (Test-Path $jreDst) { Remove-Item -Recurse -Force $jreDst }
  206. Copy-Item -Recurse -Path $jreSrc -Destination $jreDst
  207. }
  208. $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
  209. if ($userPath -notlike "*$binDir*") {
  210. [Environment]::SetEnvironmentVariable("Path", "$binDir;$userPath", "User")
  211. Write-Host ""
  212. Write-Host "Added $binDir to user PATH."
  213. Write-Host "Please restart your terminal for changes to take effect."
  214. }
  215. Write-Host ""
  216. Write-Host "opentaint installed successfully!"
  217. Write-Host "OPENTAINT_BINARY_PATH=$binDir\opentaint.exe"
  218. Write-Host "Run 'opentaint --version' to verify the installation."
  219. }
  220. finally {
  221. Remove-Item -Recurse -Force $tmpDir -ErrorAction SilentlyContinue
  222. }
  223. }
  224. Main
scripts/install/install.sh · Bundled script · 391 lines · 1 finding marked
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # OpenTaint installer for Linux and macOS
  4. # Usage:
  5. # curl -fsSL https://raw.githubusercontent.com/seqra/opentaint/main/scripts/install/install.sh | bash
    • Note: Pipes a downloaded script directly into a shell (curl | sh / wget | bash)
    • Line 6 on GitHub
  6. # curl -fsSL .../install.sh | bash -s -- v0.4.5 # exact version ('v' optional)
  7. # curl -fsSL .../install.sh | bash -s -- v0 # newest v0.x.y
  8. # curl -fsSL .../install.sh | bash -s -- v0.4 # newest v0.4.x
  9. REPO="${OPENTAINT_REPOSITORY:-seqra/opentaint}"
  10. INSTALL_DIR="${OPENTAINT_INSTALL_DIR:-}"
  11. DOWNLOADER=""
  12. # Populated by validate_version(): one of latest|exact|major|minor.
  13. VERSION_SELECTOR_KIND=""
  14. # Floating selector (e.g. v0 or v0.1) when kind is major|minor; resolved later.
  15. VERSION_SELECTOR=""
  16. # Populates VERSION_SELECTOR_KIND, VERSION_SELECTOR, VERSION_PATH_SEGMENT and
  17. # VERSION_TAG from the raw version argument.
  18. # Accepts:
  19. # (empty) -> latest
  20. # latest
  21. # X / vX (floating major, resolved to newest vX.Y.Z)
  22. # X.Y / vX.Y (floating minor, resolved to newest vX.Y.Z)
  23. # X.Y.Z / vX.Y.Z (exact, optionally with -suffix)
  24. # For floating selectors VERSION_PATH_SEGMENT is left empty and filled in later
  25. # by resolve_floating_selector() once a downloader is available.
  26. # Exits 2 on invalid input.
  27. validate_version() {
  28. local raw="${1:-latest}"
  29. if [ "$raw" = "latest" ] || [ -z "$raw" ]; then
  30. VERSION_SELECTOR_KIND="latest"
  31. VERSION_PATH_SEGMENT="latest/download"
  32. VERSION_TAG="latest"
  33. return
  34. fi
  35. if [[ "$raw" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?$ ]]; then
  36. local normalized="${raw#v}"
  37. VERSION_SELECTOR_KIND="exact"
  38. VERSION_PATH_SEGMENT="download/v${normalized}"
  39. VERSION_TAG="v${normalized}"
  40. return
  41. fi
  42. if [[ "$raw" =~ ^v?[0-9]+\.[0-9]+$ ]]; then
  43. VERSION_SELECTOR_KIND="minor"
  44. VERSION_SELECTOR="v${raw#v}"
  45. VERSION_TAG="$VERSION_SELECTOR"
  46. return
  47. fi
  48. if [[ "$raw" =~ ^v?[0-9]+$ ]]; then
  49. VERSION_SELECTOR_KIND="major"
  50. VERSION_SELECTOR="v${raw#v}"
  51. VERSION_TAG="$VERSION_SELECTOR"
  52. return
  53. fi
  54. echo "Error: invalid version '$raw'." >&2
  55. echo "Expected 'latest', 'X', 'X.Y', or 'X.Y.Z' (optionally prefixed with 'v')." >&2
  56. exit 2
  57. }
  58. # Fetches a URL to stdout using the selected downloader. Adds a GitHub token
  59. # header when OPENTAINT_GITHUB_TOKEN or GITHUB_TOKEN is set (avoids API rate
  60. # limits). Returns non-zero on failure.
  61. fetch_stdout() {
  62. local url="$1"
  63. local token="${OPENTAINT_GITHUB_TOKEN:-${GITHUB_TOKEN:-}}"
  64. case "$DOWNLOADER" in
  65. curl)
  66. if [ -n "$token" ]; then
  67. curl -fsSL -H "Authorization: Bearer $token" "$url"
  68. else
  69. curl -fsSL "$url"
  70. fi
  71. ;;
  72. wget)
  73. if [ -n "$token" ]; then
  74. wget -qO- --header="Authorization: Bearer $token" "$url"
  75. else
  76. wget -qO- "$url"
  77. fi
  78. ;;
  79. *)
  80. return 1
  81. ;;
  82. esac
  83. }
  84. # Resolves a floating major/minor selector (e.g. v0 or v0.1) to the newest
  85. # matching exact vX.Y.Z release tag by querying the GitHub releases API. Only
  86. # exact vX.Y.Z tags are considered (floating and prefixed tags are ignored),
  87. # mirroring scripts/resolve_opentaint_version.py. Prints the resolved tag.
  88. resolve_floating_selector() {
  89. local selector="$1"
  90. local page=1
  91. local bodies=""
  92. while true; do
  93. local api_url="https://api.github.com/repos/${REPO}/releases?per_page=100&page=${page}"
  94. local body
  95. if ! body="$(fetch_stdout "$api_url")"; then
  96. echo "Error: failed to query the GitHub releases API to resolve '$selector'." >&2
  97. exit 2
  98. fi
  99. if [[ "$body" =~ ^[[:space:]]*\[[[:space:]]*\][[:space:]]*$ ]]; then
  100. break
  101. fi
  102. bodies+=$'\n'"$body"
  103. page=$((page + 1))
  104. done
  105. # Match e.g. ^v0\. (major) or ^v0\.1\. (minor) against vX.Y.Z tags.
  106. local pattern
  107. if [ "$VERSION_SELECTOR_KIND" = "minor" ]; then
  108. pattern="^${selector//./\\.}\\."
  109. else
  110. pattern="^${selector}\\."
  111. fi
  112. local best
  113. best="$(printf '%s' "$bodies" \
  114. | grep -oE '"tag_name"[[:space:]]*:[[:space:]]*"v[0-9]+\.[0-9]+\.[0-9]+"' \
  115. | sed -E 's/.*"(v[0-9]+\.[0-9]+\.[0-9]+)"$/\1/' \
  116. | grep -E "$pattern" \
  117. | sed 's/^v//' \
  118. | sort -t. -k1,1n -k2,2n -k3,3n \
  119. | tail -1 || true)"
  120. if [ -z "$best" ]; then
  121. echo "Error: no release found matching selector '$selector'." >&2
  122. exit 2
  123. fi
  124. echo "v${best}"
  125. }
  126. # Prints the resolved path of an existing opentaint binary if it appears to
  127. # belong to a Homebrew installation (mirrors cli/internal/utils/updater.go
  128. # classification). Prints nothing otherwise.
  129. detect_homebrew_install() {
  130. if ! command -v opentaint >/dev/null 2>&1; then
  131. return 0
  132. fi
  133. local path resolved
  134. path="$(command -v opentaint)"
  135. # Resolve symlinks so we can compare against the real location.
  136. # readlink -f is GNU-only; fall back to realpath on macOS/BSD.
  137. if resolved="$(readlink -f "$path" 2>/dev/null)" && [ -n "$resolved" ]; then
  138. path="$resolved"
  139. elif resolved="$(realpath "$path" 2>/dev/null)" && [ -n "$resolved" ]; then
  140. path="$resolved"
  141. fi
  142. case "$(printf '%s' "$path" | tr '[:upper:]' '[:lower:]')" in
  143. */cellar/*|*/caskroom/*|*/homebrew/*)
  144. echo "$path"
  145. ;;
  146. esac
  147. }
  148. pick_downloader() {
  149. if command -v curl >/dev/null 2>&1; then
  150. DOWNLOADER="curl"
  151. return
  152. fi
  153. if command -v wget >/dev/null 2>&1; then
  154. DOWNLOADER="wget"
  155. return
  156. fi
  157. echo "Error: curl or wget is required but neither is installed." >&2
  158. echo "Install curl or wget and re-run the installer." >&2
  159. exit 1
  160. }
  161. download() {
  162. local url="$1"
  163. local output="$2"
  164. local progress="${3:-0}"
  165. case "$DOWNLOADER" in
  166. curl)
  167. if [ "$progress" = "1" ]; then
  168. curl -fSL --progress-bar -o "$output" "$url"
  169. else
  170. curl -fsSL -o "$output" "$url"
  171. fi
  172. ;;
  173. wget)
  174. if [ "$progress" = "1" ]; then
  175. wget --show-progress --progress=bar:force:noscroll -q -O "$output" "$url"
  176. else
  177. wget -q -O "$output" "$url"
  178. fi
  179. ;;
  180. *)
  181. echo "Error: no downloader configured." >&2
  182. exit 1
  183. ;;
  184. esac
  185. }
  186. detect_platform() {
  187. local os arch
  188. os="$(uname -s)"
  189. case "$os" in
  190. Linux) os="linux" ;;
  191. Darwin) os="darwin" ;;
  192. *)
  193. echo "Error: Unsupported operating system: $os" >&2
  194. echo "See https://github.com/seqra/opentaint/blob/main/docs/installation.md for alternatives." >&2
  195. exit 1
  196. ;;
  197. esac
  198. arch="$(uname -m)"
  199. case "$arch" in
  200. x86_64|amd64) arch="amd64" ;;
  201. arm64|aarch64) arch="arm64" ;;
  202. *)
  203. echo "Error: Unsupported architecture: $arch" >&2
  204. echo "See https://github.com/seqra/opentaint/blob/main/docs/installation.md for alternatives." >&2
  205. exit 1
  206. ;;
  207. esac
  208. # Rosetta-2: a shell running as amd64 under Rosetta on Apple Silicon
  209. # should download the native arm64 archive instead.
  210. if [ "$os" = "darwin" ] && [ "$arch" = "amd64" ]; then
  211. if [ "$(sysctl -n sysctl.proc_translated 2>/dev/null)" = "1" ]; then
  212. arch="arm64"
  213. fi
  214. fi
  215. echo "${os}_${arch}"
  216. }
  217. verify_checksum() {
  218. local archive_path="$1"
  219. local archive_name="$2"
  220. local checksums_url="${DOWNLOAD_BASE_URL}/checksums.txt"
  221. echo "Verifying checksum..."
  222. if ! download "$checksums_url" "$tmp_dir/checksums.txt" 2>/dev/null; then
  223. echo "Warning: Could not download checksums.txt, skipping verification." >&2
  224. return 0
  225. fi
  226. local expected
  227. expected="$(grep " ${archive_name}$" "$tmp_dir/checksums.txt" | awk '{print $1}')"
  228. if [ -z "$expected" ]; then
  229. echo "Warning: No checksum found for ${archive_name}, skipping verification." >&2
  230. return 0
  231. fi
  232. local actual
  233. if command -v sha256sum >/dev/null 2>&1; then
  234. actual="$(sha256sum "$archive_path" | awk '{print $1}')"
  235. elif command -v shasum >/dev/null 2>&1; then
  236. actual="$(shasum -a 256 "$archive_path" | awk '{print $1}')"
  237. else
  238. echo "Warning: No SHA256 tool found, skipping verification." >&2
  239. return 0
  240. fi
  241. if [ "$expected" != "$actual" ]; then
  242. echo "Error: Checksum verification failed!" >&2
  243. echo " Expected: $expected" >&2
  244. echo " Actual: $actual" >&2
  245. exit 1
  246. fi
  247. echo "Checksum verified."
  248. }
  249. get_install_dir() {
  250. if [ -n "$INSTALL_DIR" ]; then
  251. echo "$INSTALL_DIR"
  252. return
  253. fi
  254. if [ "$(id -u)" = "0" ]; then
  255. echo "/usr/local/lib/opentaint"
  256. else
  257. echo "$HOME/.opentaint/install"
  258. fi
  259. }
  260. main() {
  261. local platform archive_name url install_dir bin_dir
  262. validate_version "${1:-}"
  263. pick_downloader
  264. local existing_brew
  265. existing_brew="$(detect_homebrew_install)"
  266. if [ -n "$existing_brew" ] && [ "${OPENTAINT_FORCE:-0}" != "1" ]; then
  267. echo "Error: opentaint is already installed via Homebrew at $existing_brew" >&2
  268. echo "Run 'brew upgrade --cask opentaint' to update, or set" >&2
  269. echo "OPENTAINT_FORCE=1 to install side-by-side anyway." >&2
  270. exit 3
  271. fi
  272. # Floating major/minor selectors are resolved to an exact tag, unless the
  273. # caller already pinned a fully-resolved download base URL (e.g. CI).
  274. if [ -z "${OPENTAINT_DOWNLOAD_BASE_URL:-}" ] && \
  275. { [ "$VERSION_SELECTOR_KIND" = "major" ] || [ "$VERSION_SELECTOR_KIND" = "minor" ]; }; then
  276. echo "Resolving ${VERSION_SELECTOR} to an exact release..."
  277. local resolved_tag
  278. resolved_tag="$(resolve_floating_selector "$VERSION_SELECTOR")"
  279. VERSION_PATH_SEGMENT="download/${resolved_tag}"
  280. VERSION_TAG="$resolved_tag"
  281. fi
  282. DOWNLOAD_BASE_URL="${OPENTAINT_DOWNLOAD_BASE_URL:-https://github.com/${REPO}/releases/${VERSION_PATH_SEGMENT}}"
  283. echo "Version: $VERSION_TAG"
  284. echo "Detecting platform..."
  285. platform="$(detect_platform)"
  286. echo "Platform: $platform"
  287. archive_name="opentaint-full_${platform}.tar.gz"
  288. url="${DOWNLOAD_BASE_URL}/${archive_name}"
  289. install_dir="$(get_install_dir)"
  290. echo "Install directory: $install_dir"
  291. tmp_dir="$(mktemp -d)"
  292. trap 'rm -rf "$tmp_dir"' EXIT
  293. echo "Downloading ${archive_name}..."
  294. download "$url" "$tmp_dir/$archive_name" 1
  295. verify_checksum "$tmp_dir/$archive_name" "$archive_name"
  296. echo "Extracting..."
  297. tar -xzf "$tmp_dir/$archive_name" -C "$tmp_dir"
  298. echo "Installing to $install_dir..."
  299. mkdir -p "$install_dir"
  300. cp "$tmp_dir/opentaint" "$install_dir/opentaint"
  301. chmod +x "$install_dir/opentaint"
  302. # Install bundled lib and jre if present (next to the binary)
  303. if [ -d "$tmp_dir/lib" ]; then
  304. mkdir -p "$install_dir/lib"
  305. cp -r "$tmp_dir/lib/"* "$install_dir/lib/"
  306. fi
  307. if [ -d "$tmp_dir/jre" ]; then
  308. mkdir -p "$install_dir/jre"
  309. cp -r "$tmp_dir/jre/"* "$install_dir/jre/"
  310. fi
  311. # For root installs, symlink into /usr/local/bin so the binary is in PATH
  312. # while keeping lib/jre next to the actual binary for bundled path resolution
  313. bin_dir="$install_dir"
  314. if [ "$(id -u)" = "0" ] && [ -z "$INSTALL_DIR" ]; then
  315. ln -sf "$install_dir/opentaint" /usr/local/bin/opentaint
  316. bin_dir="/usr/local/bin"
  317. fi
  318. echo ""
  319. echo "opentaint installed successfully!"
  320. echo ""
  321. echo "OPENTAINT_BINARY_PATH=$bin_dir/opentaint"
  322. echo ""
  323. # Check if bin_dir is in PATH
  324. case ":$PATH:" in
  325. *":$bin_dir:"*)
  326. echo "Run 'opentaint --version' to verify the installation."
  327. ;;
  328. *)
  329. echo "Add the following to your shell profile to use opentaint:"
  330. echo ""
  331. echo " export PATH=\"$bin_dir:\$PATH\""
  332. echo ""
  333. echo "Then restart your shell or run the export command above."
  334. ;;
  335. esac
  336. }
  337. main "$@"

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.