Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
serpro69 committed Aug 13, 2024
1 parent 0cb13f3 commit d00fa42
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions docs/src/orchid/resources/pages/extensions/blns-extension.md
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.

0 comments on commit d00fa42

Please sign in to comment.