Socket
Socket
Sign inDemoInstall

weapon-regex

Package Overview
Dependencies
0
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.2.1

36

index.d.ts

@@ -28,3 +28,2 @@ export interface Location {

levels: number[];
description: string;
}

@@ -60,22 +59,2 @@

/** Mutate a regex pattern with the given options.
*
* @param pattern
* Input regex string
* @param options
* JavaScript object for Mutation options
* {{{
* {
* mutators: [Mutators to be used for mutation. If this is `null`, all built-in mutators will be used.],
* mutationLevels: [Target mutation levels. If this is `null`, the `mutators`, will not be filtered.],
* flavor: [Regex flavor. By the default, `ParerFlavorJS` will be used.]
* }
* }}}
* @return
* A JavaScript Array of [[weaponregex.model.mutation.Mutant]] if can be parsed, or throw an exception otherwise
* @deprecated
* Use `mutate(pattern, flags, options)` instead. This will be removed in the future.". @since 0.7.x
*/
export function mutate(pattern: string, options: MutationOptions): Mutant[];
/** Mutate a regex pattern and flags with the given options.

@@ -86,5 +65,5 @@ *

* @param flags
* Regex flags or `undefined`
* Optional regex flags
* @param options
* JavaScript object for Mutation options
* Optional JavaScript object for Mutation options
* {{{

@@ -100,13 +79,4 @@ * {

*/
export function mutate(pattern: string, flags: string | undefined, options: MutationOptions): Mutant[];
export function mutate(pattern: string, flags?: string, options?: MutationOptions): Mutant[];
/** Mutate a regex pattern with the default options.
*
* @param pattern
* Input regex string
* @return
* A JavaScript Array of [[weaponregex.model.mutation.Mutant]] if can be parsed, or throw an exception otherwise
*/
export function mutate(pattern: string): Mutant[];
/** JS Map that maps from a token mutator class names to the associating token mutator

@@ -113,0 +83,0 @@ */

9

package.json
{
"name": "weapon-regex",
"type": "module",
"version": "1.1.1",
"version": "1.2.1",
"description": "Weapon regeX mutates regular expressions for use in mutation testing.",
"main": "./index.js",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./core/target/js-3/weapon-regex-opt/main.js"
}
},
"repository": {

@@ -8,0 +13,0 @@ "type": "git",

@@ -14,3 +14,4 @@ [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fstryker-mutator%2Fweapon-regex%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/stryker-mutator/weapon-regex/main)

The JavaScript version of the library is generated from Scala using [Scala.js](https://www.scala-js.org/).
The generated mutant regular expressions cover human errors, such as edge cases and typos. A list of provided mutators is given below.
The generated mutant regular expressions cover human errors, such as edge cases and typos. A list of provided mutators
is given below.
For an introduction to mutation testing, see [Stryker's website](https://stryker-mutator.io/).

@@ -26,3 +27,4 @@

Add Weapon regeX to your `build.sbt` [![Maven Central](https://img.shields.io/maven-central/v/io.stryker-mutator/weapon-regex_3.svg?label=Maven%20Central&colorB=brightgreen)](https://search.maven.org/artifact/io.stryker-mutator/weapon-regex_3):
Add Weapon regeX to
your `build.sbt` [![Maven Central](https://img.shields.io/maven-central/v/io.stryker-mutator/weapon-regex_3.svg?label=Maven%20Central&colorB=brightgreen)](https://search.maven.org/artifact/io.stryker-mutator/weapon-regex_3):

@@ -39,4 +41,4 @@ ```scala

WeaponRegeX.mutate("^abc(d+|[xyz])$") match {
case Right(mutants) => mutants map (_.pattern)
case Left(e) => throw new RuntimeException(e)
case Right(mutants) => mutants map (_.pattern)
case Left(e) => throw new RuntimeException(e)
}

@@ -78,3 +80,3 @@ // res0: Seq[String] = List(

mutants.forEach((mutant) => {
console.log(mutant.pattern);
console.log(mutant.pattern);
});

@@ -99,7 +101,7 @@ ```

def mutate(
pattern: String,
mutators: Seq[TokenMutator] = BuiltinMutators.all,
mutationLevels: Seq[Int] = null,
flavor: ParserFlavor = ParserFlavorJVM
): Either[String, Seq[Mutant]] = ???
pattern : String,
mutators : Seq[TokenMutator] = BuiltinMutators.all,
mutationLevels: Seq[Int] = null,
flavor : ParserFlavor = ParserFlavorJVM
): Either[String, Seq[Mutant]] = ???
```

@@ -117,7 +119,9 @@

This function will return a `Right` with `Seq[Mutant]` if it can be parsed, or a `Left` with the error message otherwise.
This function will return a `Right` with `Seq[Mutant]` if it can be parsed, or a `Left` with the error message
otherwise.
## JavaScript
The `mutate` function can be called with regular expression flags and an options object to control which mutators and which parser flavor should be used in the mutation process:
The `mutate` function can be called with regular expression flags and an options object to control which mutators and
which parser flavor should be used in the mutation process:

@@ -128,5 +132,5 @@ ```js

let mutants = wrx.mutate('^abc(d+|[xyz])$', 'u', {
mutators: Array.from(wrx.mutators.values()),
mutationLevels: [1, 2, 3],
flavor: ParserFlavorJS,
mutators: Array.from(wrx.mutators.values()),
mutationLevels: [1, 2, 3],
flavor: wrx.ParserFlavorJS,
});

@@ -136,3 +140,4 @@ ```

Both options can be omitted, and have the same functionality as the options described in the Scala
API section. By default in JS the JS parser flavor is used. You can get a map of mutators from the `mutators` attribute of the library. It is
API section. By default in JS the JS parser flavor is used. You can get a map of mutators from the `mutators` attribute
of the library. It is
a `Map<string, Mutator>` from string (mutator name) to a mutator object.

@@ -146,26 +151,26 @@

| Name | 1 | 2 | 3 |
| --------------------------------------------------------------- | --- | --- | --- |
| [BOLRemoval](#bolremoval) | ✅ | ✅ | ✅ |
| [EOLRemoval](#eolremoval) | ✅ | ✅ | ✅ |
| [BOL2BOI](#bol2boi) | | ✅ | ✅ |
| [EOL2EOI](#eol2eoi) | | ✅ | ✅ |
| [CharClassNegation](#charclassnegation) | ✅ |
| [CharClassChildRemoval](#charclasschildremoval) | | ✅ | ✅ |
| [CharClassAnyChar](#charclassanychar) | | ✅ | ✅ |
| [CharClassRangeModification](#charclassrangemodification) | | | ✅ |
| [PredefCharClassNegation](#predefcharclassnegation) | ✅ |
| [PredefCharClassNullification](#predefcharclassnullification) | | ✅ | ✅ |
| [PredefCharClassAnyChar](#predefcharclassanychar) | | ✅ | ✅ |
| [POSIXCharClassNegation](#posixcharclassnegation) | ✅ |
| [QuantifierRemoval](#quantifierremoval) | ✅ |
| [QuantifierNChange](#quantifiernchange) | | ✅ | ✅ |
| [QuantifierNOrMoreModification](#quantifiernormoremodification) | | ✅ | ✅ |
| [QuantifierNOrMoreChange](#quantifiernormorechange) | | ✅ | ✅ |
| [QuantifierNMModification](#quantifiernmmodification) | | ✅ | ✅ |
| [QuantifierShortModification](#quantifiershortmodification) | | ✅ | ✅ |
| [QuantifierShortChange](#quantifiershortchange) | | ✅ | ✅ |
| [QuantifierReluctantAddition](#quantifierreluctantaddition) | | | ✅ |
| [GroupToNCGroup](#grouptoncgroup) | | ✅ | ✅ |
| [LookaroundNegation](#lookaroundnegation) | ✅ | ✅ | ✅ |
| Name | 1 | 2 | 3 |
|-----------------------------------------------------------------|---|---|---|
| [BOLRemoval](#bolremoval) | ✅ | ✅ | ✅ |
| [EOLRemoval](#eolremoval) | ✅ | ✅ | ✅ |
| [BOL2BOI](#bol2boi) | | ✅ | ✅ |
| [EOL2EOI](#eol2eoi) | | ✅ | ✅ |
| [CharClassNegation](#charclassnegation) | ✅ |
| [CharClassChildRemoval](#charclasschildremoval) | | ✅ | ✅ |
| [CharClassAnyChar](#charclassanychar) | | ✅ | ✅ |
| [CharClassRangeModification](#charclassrangemodification) | | | ✅ |
| [PredefCharClassNegation](#predefcharclassnegation) | ✅ |
| [PredefCharClassNullification](#predefcharclassnullification) | | ✅ | ✅ |
| [PredefCharClassAnyChar](#predefcharclassanychar) | | ✅ | ✅ |
| [UnicodeCharClassNegation](#unicodecharclassnegation) | ✅ |
| [QuantifierRemoval](#quantifierremoval) | ✅ |
| [QuantifierNChange](#quantifiernchange) | | ✅ | ✅ |
| [QuantifierNOrMoreModification](#quantifiernormoremodification) | | ✅ | ✅ |
| [QuantifierNOrMoreChange](#quantifiernormorechange) | | ✅ | ✅ |
| [QuantifierNMModification](#quantifiernmmodification) | | ✅ | ✅ |
| [QuantifierShortModification](#quantifiershortmodification) | | ✅ | ✅ |
| [QuantifierShortChange](#quantifiershortchange) | | ✅ | ✅ |
| [QuantifierReluctantAddition](#quantifierreluctantaddition) | | | ✅ |
| [GroupToNCGroup](#grouptoncgroup) | | ✅ | ✅ |
| [LookaroundNegation](#lookaroundnegation) | ✅ | ✅ | ✅ |

@@ -179,3 +184,3 @@ ## Boundary Mutators

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `^abc` | `abc` |

@@ -190,3 +195,3 @@

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `abc$` | `abc` |

@@ -201,3 +206,3 @@

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `^abc` | `\Aabc` |

@@ -212,3 +217,3 @@

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `abc$` | `abc\z` |

@@ -225,3 +230,3 @@

| Original | Mutated |
| -------- | -------- |
|----------|----------|
| `[abc]` | `[^abc]` |

@@ -237,3 +242,3 @@ | `[^abc]` | `[abc]` |

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `[abc]` | `[bc]` |

@@ -250,3 +255,3 @@ | `[abc]` | `[ac]` |

| Original | Mutated |
| -------- | -------- |
|----------|----------|
| `[abc]` | `[\w\W]` |

@@ -261,3 +266,3 @@

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `[b-y]` | `[a-y]` |

@@ -277,3 +282,3 @@ | `[b-y]` | `[c-y]` |

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `\d` | `\D` |

@@ -293,3 +298,3 @@ | `\D` | `\d` |

| Original | Mutated |
| -------- | ------- |
|----------|---------|
| `\d` | `d` |

@@ -310,3 +315,3 @@ | `\D` | `D` |

| Original | Mutated |
| -------- | -------- |
|----------|----------|
| `\d` | `[\d\D]` |

@@ -321,8 +326,8 @@ | `\D` | `[\D\d]` |

### POSIXCharClassNegation
### UnicodeCharClassNegation
Flips the sign of a POSIX character class.
Flips the sign of a Unicode character class.
| Original | Mutated |
| ----------- | ----------- |
|-------------|-------------|
| `\p{Alpha}` | `\P{Alpha}` |

@@ -341,3 +346,3 @@ | `\P{Alpha}` | `\p{Alpha}` |

| Original | Mutated |
| ----------- | ------- |
|-------------|---------|
| `abc?` | `abc` |

@@ -363,3 +368,3 @@ | `abc*` | `abc` |

| Original | Mutated |
| -------- | ---------- |
|----------|------------|
| `abc{9}` | `abc{0,9}` |

@@ -376,3 +381,3 @@ | `abc{9}` | `abc{9,}` |

| Original | Mutated |
| --------- | ---------- |
|-----------|------------|
| `abc{9,}` | `abc{8,}` |

@@ -388,3 +393,3 @@ | `abc{9,}` | `abc{10,}` |

| Original | Mutated |
| --------- | -------- |
|-----------|----------|
| `abc{9,}` | `abc{9}` |

@@ -400,3 +405,3 @@

| Original | Mutated |
| ---------- | ----------- |
|------------|-------------|
| `abc{3,9}` | `abc{2,9}` |

@@ -416,3 +421,3 @@ | `abc{3,9}` | `abc{4,9}` |

| Original | Mutated |
| -------- | ---------- |
|----------|------------|
| `abc?` | `abc{1,1}` |

@@ -432,3 +437,3 @@ | `abc?` | `abc{0,0}` |

| Original | Mutated |
| -------- | -------- |
|----------|----------|
| `abc*` | `abc{0}` |

@@ -444,3 +449,3 @@ | `abc+` | `abc{1}` |

| Original | Mutated |
| ----------- | ------------ |
|-------------|--------------|
| `abc?` | `abc??` |

@@ -462,3 +467,3 @@ | `abc*` | `abc*?` |

| Original | Mutated |
| -------- | --------- |
|----------|-----------|
| `(abc)` | `(?:abc)` |

@@ -473,3 +478,3 @@

| Original | Mutated |
| ---------- | ---------- |
|------------|------------|
| `(?=abc)` | `(?!abc)` |

@@ -476,0 +481,0 @@ | `(?!abc)` | `(?=abc)` |

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc