Skip to content

Commit

Permalink
Merge pull request #336 from ninoseki/add-sort
Browse files Browse the repository at this point in the history
feat: add sort option
  • Loading branch information
ninoseki authored Oct 12, 2024
2 parents 39bd94c + 2474bfa commit 60a519b
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 72 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ $ ioc-extractor --help
Usage: ioc-extractor [options]

Options:
-ns, --no-strict Disable strict option
-nr, --no-refang Disable refang option
-p, --punycode Enable punycode option
-h, --help display help for command
--no-strict Disable strict option
--no-refang Disable refang option
--no-sort Disable sort option
-p, --punycode Enable punycode option
-h, --help display help for command
```

```bash
Expand Down Expand Up @@ -79,9 +80,10 @@ console.log(ioc.domains);

`extractIOC` takes the following options:

- [strict](#strict)
- [refang](#refang)
- [punycode](#punycode)
- [refang](#refang)
- [sort](#sort)
- [strict](#strict)

If you want to extract a specific type of IoC, you can use extract function.

Expand Down Expand Up @@ -109,6 +111,7 @@ const md5s = extractMD5s(refanged);

Network related extract functions (e.g. `extractDomains`) can take the following options:

- [sort](#sort)
- [strict](#strict)

See [docs](https://ninoseki.github.io/ioc-extractor/) for more details.
Expand Down Expand Up @@ -157,6 +160,10 @@ Whether to do refang or not. Defaults to `false`.

Whether to do [Punycode](https://en.wikipedia.org/wiki/Punycode) conversion or not. Defaults to `false`.

### `sort`

Whether to sort values or not. Defaults to `true`.

## Alternatives

- [cmu-sei/cyobstract](https://github.com/cmu-sei/cyobstract)
Expand Down
11 changes: 11 additions & 0 deletions spec/aux/extractors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@ import {
extractSSDEEP,
extractURL,
extractXMR,
matchesWithRegExp,
} from "@/aux/extractors";

describe("matchesWithRegExp", () => {
test.each([
["a b c d", /\w/g, { sort: true }, ["a", "b", "c", "d"]],
["d c b a", /\w/g, { sort: true }, ["a", "b", "c", "d"]],
["d c b a", /\w/g, { sort: false }, ["d", "c", "b", "a"]],
])(".matchesWithRegExp(%s)", (value, regex, options, expected) => {
expect(matchesWithRegExp(value, regex, options)).toEqual(expected);
});
});

describe("extractMD5", () => {
test.each([
["874058e8d8582bf85c115ce319c5b0af", "874058e8d8582bf85c115ce319c5b0af"],
Expand Down
Loading

0 comments on commit 60a519b

Please sign in to comment.