
Bindings for the Gitleaks secret-detection engine via JNA; implements IMatcher for angryscan-core, supports default/custom TOML rules, bundled native libraries, easy scanning and cleanup.
Kotlin Multiplatform library providing bindings for the Gitleaks secret detection engine.
Note: This library is a Kotlin wrapper around the original Gitleaks project. For the original Go-based CLI tool and documentation, please visit the official Gitleaks repository.
angryscan-gitleaks provides Kotlin Multiplatform bindings over the Go libgitleaks shared library. It implements the IMatcher interface from org.angryscan:core, allowing you to use Gitleaks' powerful secret detection capabilities in your Kotlin/JVM applications.
The library uses JNA (Java Native Access) to load and interact with the native libgitleaks shared library, which is built from the Go source code in this repository.
org.angryscan:core IMatcher interface for easy integrationdependencies {
implementation("org.angryscan:gitleaks:0.1.0")
}dependencies {
implementation 'org.angryscan:gitleaks:0.1.0'
}<dependency>
<groupId>org.angryscan</groupId>
<artifactId>gitleaks</artifactId>
<version>0.1.0</version>
</dependency>import org.angryscan.gitleaks.matcher.GitleaksMatcher
// Initialize the matcher with default Gitleaks configuration
GitleaksMatcher.init(useDefaultConfig = true)
try {
// Scan text for secrets
val text = "GITHUB_TOKEN=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"
val matches = GitleaksMatcher.scan(text)
matches.forEach { match ->
println("Found secret: ${match.value}")
println("Position: ${match.startPosition}-${match.endPosition}")
println("Context: ...${match.before}${match.value}${match.after}...")
}
} finally {
// Clean up resources
GitleaksMatcher.close()
}import org.angryscan.gitleaks.matcher.GitleaksMatcher
// Define custom detection rules
val customConfig = """
[[rules]]
id = 'custom-api-key'
description = 'Custom API Key Pattern'
regex = '''api_key_[A-Z0-9]{32}'''
""".trimIndent()
// Initialize with custom configuration
GitleaksMatcher.init(useDefaultConfig = false, configToml = customConfig)
try {
val text = "api_key_ABCD1234EFGH5678IJKL9012MNOP3456"
val matches = GitleaksMatcher.scan(text)
// Process matches...
} finally {
GitleaksMatcher.close()
}import org.angryscan.common.engine.IMatcher
import org.angryscan.gitleaks.matcher.GitleaksMatcher
// GitleaksMatcher implements IMatcher from org.angryscan:core
val matcher: IMatcher = GitleaksMatcher
// Initialize before use
GitleaksMatcher.init(useDefaultConfig = true)
try {
// Use with angryscan-core engine
val matches = matcher.scan("Your text to scan here")
// Process matches...
} finally {
GitleaksMatcher.close()
}libgitleaks library from the Go source code.To build the library from source:
Build the native library (required):
# For your platform
bash build-scripts/build-linux.sh # Linux
bash build-scripts/build-windows.sh # Windows
bash build-scripts/build-darwin.sh # macOS
# Or build all platforms
bash build-scripts/build-all.shBuild the Kotlin library:
cd kotlin
./gradlew buildRun tests:
cd kotlin
./gradlew testThe library follows this high-level architecture:
libgitleaks shared library (libgitleaks.so/.dll/.dylib) provides the core detection engineGitleaksMatcher provides a clean Kotlin API implementing IMatcher
The library supports both default and custom Gitleaks configurations:
For more information about Gitleaks configuration format, see the official Gitleaks documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues related to:
Kotlin Multiplatform library providing bindings for the Gitleaks secret detection engine.
Note: This library is a Kotlin wrapper around the original Gitleaks project. For the original Go-based CLI tool and documentation, please visit the official Gitleaks repository.
angryscan-gitleaks provides Kotlin Multiplatform bindings over the Go libgitleaks shared library. It implements the IMatcher interface from org.angryscan:core, allowing you to use Gitleaks' powerful secret detection capabilities in your Kotlin/JVM applications.
The library uses JNA (Java Native Access) to load and interact with the native libgitleaks shared library, which is built from the Go source code in this repository.
org.angryscan:core IMatcher interface for easy integrationdependencies {
implementation("org.angryscan:gitleaks:0.1.0")
}dependencies {
implementation 'org.angryscan:gitleaks:0.1.0'
}<dependency>
<groupId>org.angryscan</groupId>
<artifactId>gitleaks</artifactId>
<version>0.1.0</version>
</dependency>import org.angryscan.gitleaks.matcher.GitleaksMatcher
// Initialize the matcher with default Gitleaks configuration
GitleaksMatcher.init(useDefaultConfig = true)
try {
// Scan text for secrets
val text = "GITHUB_TOKEN=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"
val matches = GitleaksMatcher.scan(text)
matches.forEach { match ->
println("Found secret: ${match.value}")
println("Position: ${match.startPosition}-${match.endPosition}")
println("Context: ...${match.before}${match.value}${match.after}...")
}
} finally {
// Clean up resources
GitleaksMatcher.close()
}import org.angryscan.gitleaks.matcher.GitleaksMatcher
// Define custom detection rules
val customConfig = """
[[rules]]
id = 'custom-api-key'
description = 'Custom API Key Pattern'
regex = '''api_key_[A-Z0-9]{32}'''
""".trimIndent()
// Initialize with custom configuration
GitleaksMatcher.init(useDefaultConfig = false, configToml = customConfig)
try {
val text = "api_key_ABCD1234EFGH5678IJKL9012MNOP3456"
val matches = GitleaksMatcher.scan(text)
// Process matches...
} finally {
GitleaksMatcher.close()
}import org.angryscan.common.engine.IMatcher
import org.angryscan.gitleaks.matcher.GitleaksMatcher
// GitleaksMatcher implements IMatcher from org.angryscan:core
val matcher: IMatcher = GitleaksMatcher
// Initialize before use
GitleaksMatcher.init(useDefaultConfig = true)
try {
// Use with angryscan-core engine
val matches = matcher.scan("Your text to scan here")
// Process matches...
} finally {
GitleaksMatcher.close()
}libgitleaks library from the Go source code.To build the library from source:
Build the native library (required):
# For your platform
bash build-scripts/build-linux.sh # Linux
bash build-scripts/build-windows.sh # Windows
bash build-scripts/build-darwin.sh # macOS
# Or build all platforms
bash build-scripts/build-all.shBuild the Kotlin library:
cd kotlin
./gradlew buildRun tests:
cd kotlin
./gradlew testThe library follows this high-level architecture:
libgitleaks shared library (libgitleaks.so/.dll/.dylib) provides the core detection engineGitleaksMatcher provides a clean Kotlin API implementing IMatcher
The library supports both default and custom Gitleaks configurations:
For more information about Gitleaks configuration format, see the official Gitleaks documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues related to: