
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
io.cucumber:gherkin-utils
Advanced tools
Gherkin utils for doing things such as walking a Gherkin tree or pretty printing Gherkin files.
Utilities for working with Gherkin documents and AST
.feature
files to .feature.md
Gherkin Utils is available on npm for JavaScript:
npm install @cucumber/gherkin-utils
Gherkin Utils is available on Maven Central for Java, by adding the dependency to your pom.xml
:
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin-utils</artifactId>
<version>9.0.0</version>
</dependency>
</dependencies>
To run Gherkin Utils as a formatter, try any of the following:
# Format `file.feature`
> npx @cucumber/gherkin-utils format features/file.feature
# Format `file.feature` and `other.feature`
> npx @cucumber/gherkin-utils format features/file.feature features/other.feature
# Format feature files directly within `features/`
> npx @cucumber/gherkin-utils format features/*.feature
# Format feature files ending with `_test.feature` in `features`
> npx @cucumber/gherkin-utils format features/*_test.feature
# Format feature files within immediate subdirectories of `features/`
> npx @cucumber/gherkin-utils format features/**/*.feature
To convert gherkin feature files to Markdown with Gherkin - or the other way around - while formatting, try the following:
# Format `file.feature` to gherkin markdown `file.feature.md`
npx @cucumber/gherkin-utils format --to-syntax=markdown features/file.feature
# Format `file.feature.md` to gherkin `file.feature`
npx @cucumber/gherkin-utils format --to-syntax=gherkin features/file.feature.md
For more details on usage, see the help menu.
npx @cucumber/gherkin-utils --help
This module can also be used as a library. It provides two main utilities, pretty
and gherkinDocumentWalker
.
This function takes a GherkinDocument as input and returns a pretty-printed representation in Gherkin or Markdown.
import { AstBuilder, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin'
import { pretty } from '@cucumber/gherkin-utils'
import { IdGenerator } from '@cucumber/messages'
const uuidFn = IdGenerator.uuid()
const builder = new AstBuilder(uuidFn)
const matcher = new GherkinClassicTokenMatcher()
const parser = new Parser(builder, matcher)
const feature = `Feature:
Scenario:
Given step text`
const gherkinDocument = parser.parse(feature)
const formattedGherkinFeature = pretty(gherkinDocument)
/*
Feature:
Scenario:
Given step text
*/
const formattedGherkinMarkdownFeature = pretty(gherkinDocument, 'markdown')
/*
# Feature:
## Scenario:
* Given step text
*/
The GherkinDocumentWalker is a class for walking and filtering the AST produced by Gherkin after parsing a feature file.
When running walkGherkinDocument
on a GherkinDocument, it will produce a deep copy of the object.
It takes two arguments upon creation:
Filtering keeps the meaning of the original GherkinDocument, which means:
Background
was present, it will always be in the Feature
(or Rule
)By default, all elements are accepted, which means that if you want to do filtering you should reject all other elements. To ease this, we also provide the rejectAllFilters
.
Here's an example:
import { GherkinDocumentWalker, rejectAllFilters } from '@cucumber/gherkin-utils';
// Only keeps scenarios which name include 'magic'
const filter = new GherkinDocumentWalker({
...rejectAllFilters,
...{ acceptScenario: (scenario) => scenario.name.includes('magic') },
})
// Makes a list with all the scenario names
const allScenarioNames: string[] = []
const scenarioNameFinder = new GherkinDocumentWalker({}, {
handleScenario: (scenario) => allScenarioNames.push(scenario.name),
})
FAQs
Unknown package
We found that io.cucumber:gherkin-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.