-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
docs/src/orchid/resources/pages/extensions/blns-extension.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
--- | ||
|
||
# Big List of Naughty Strings Extension | ||
|
||
## TOC | ||
|
||
- [About](#about) | ||
- [Usage](#usage) | ||
- [Installation](#installation) | ||
- [Generate Arb Extensions](#generate-arb-extensions) | ||
- [Random Class Instance ARBs](#random-class-instance-arb) | ||
|
||
## About | ||
|
||
Kotlin-faker `blns` artifact provides convenience functions for returning strings from [The Big List of Naughty Strings](https://github.com/minimaxir/big-list-of-naughty-strings) - a list of strings which have a high probability of causing issues when used as user-input data, and can therefore be quite useful in testing. | ||
|
||
## Disclaimer | ||
|
||
> The Big List of Naughty Strings is intended to be used for _software you own and manage_. Some of the Naughty Strings can indicate security vulnerabilities, and as a result using such strings with third-party software may be a crime. The maintainer is not responsible for any negative actions that result from the use of the list. | ||
> | ||
> Additionally, the Big List of Naughty Strings is not a fully-comprehensive substitute for formal security/penetration testing for your service. | ||
## Usage | ||
|
||
### Installation | ||
|
||
- ① add the core `kotlin-faker` dependency to the test classpath | ||
- ② then add the dependency for the `kotlin-faker-blns` extension | ||
|
||
{% tabs %} | ||
|
||
{% kotlin "Kotlin" %} | ||
{% filter compileAs('md') %} | ||
|
||
```kotlin | ||
dependencies { | ||
testImplementation("io.github.serpro69:kotlin-faker:$fakerVersion") // ① | ||
testImplementation("io.github.serpro69:kotlin-faker-blns:$fakerVersion") // ② | ||
} | ||
``` | ||
|
||
{% endfilter %} | ||
{% endkotlin %} | ||
|
||
{% endtabs %} | ||
|
||
{% btc %}{% endbtc %} | ||
|
||
<br> | ||
|
||
### Using the Big List of Naughty Strings | ||
|
||
The `Blns` class provides properties and functions to get all strings, as well as a sublist of strings, and a single random string. | ||
|
||
There is also corresponding functionality for getting base64-encoded strings. | ||
|
||
For example, using [JUnit5 Parameterized Testing](https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests) capabilities: | ||
|
||
- ① Create an instance of `Blns` class | ||
- ② Get `all` strings | ||
- ③ Get a `sublist` of strings | ||
- ④ Get a `random` string | ||
- ⑤ Test your inputs | ||
- ⑥ Profit 💸 | ||
|
||
{% tabs %} | ||
|
||
{% kotlin "Kotlin" %} | ||
{% filter compileAs('md') %} | ||
|
||
```kotlin | ||
class Test { | ||
@ParameterizedTest | ||
@MethodSource("allStrings") // ⑤ | ||
fun `test input with a naughty string`(s: String) { | ||
inputField.sendKeys(s) // ⑤ | ||
} | ||
|
||
companion object { | ||
private val blns = blns { /*faker configuration*/ } // ① | ||
@JvmStatic private fun allStrings() = blns.all.stream() // ② | ||
@JvmStatic private fun allBase64 () = blns.allBase64.stream() // ② | ||
@JvmStatic private fun sublist() = blns.sublist(10).stream() // ③ | ||
@JvmStatic private fun sublistBase64() = blns.sublist(10, base64 = true).stream() // ③ | ||
val randomString: String get() = blns.random() // ④ | ||
val randomBase64String: String get() = blns.random(base64 = true) // ④ | ||
} | ||
} | ||
``` | ||
|
||
{% endfilter %} | ||
{% endkotlin %} | ||
|
||
{% endtabs %} | ||
|
||
{% btc %}{% endbtc %} | ||
|
||
<br> | ||
|
||
## Credits | ||
|
||
The input for this extension is maintained by [github.com/minimaxir](https://github.com/minimaxir) at https://github.com/minimaxir/big-list-of-naughty-strings. |