
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
fsm-validator
Advanced tools
#fsm-validator
fsm-validator is an alternative to regular expressions however it allows you to write them in a more programmatic way. This could come in very handy if you'd want to generate a different fsm depending on some input.
this is an example for what an email rule might look like \[a-z]+@[a-z]+\.[a-z]+\
and this is the what it would like using fsm-validator
start.plus(letters).normal('@').plus(letters).normal('.').plus(letters).accepting = true;
For an explanation about finite state machines there is a very good video about it on numberphile.

First of all you need to make a finite state machine like the one in the image above. you do this by creating a Start state and then using it's methods to build it up. You can set a states accepting attribute to true this will mark it as a legal endstate, in 99% of all cases you'd want your final state to be the "accepting" state.
var letters = "abcdefghijklmonpqrstuvwxyz";
var start = new State();
start.plus(letters).normal(at).plus(letters).normal(dot).plus(letters).accepting = true;
Once you've made your fsm you can pass it a string and it will walk the fsm seeing if it fits the pattern. The total for the email rule looks like this.
var State = require("./js2/State");
var letters = "abcdefghijklmnopqrstuvwxyz";
var start = new State();
start.plus(letters).normal("@").plus(letters).normal(".").plus(letters).accepting = true;
console.log(start.consume("paul@gmail.com"));





The implementation of these finite state machines is a little different than regular expressions.
Normally regular expressions consider a string valid if there is any possible way to complete the finite state machine.
However the way these fsm's are implemented is that they will take the first path that is available, so the order in which you specify the rules
does matter. For instance this regex \a+a\ would allow aa but start.plus("a").normal("a") wouldn't because
it would keep looping in the a+ part and never reach the accepting state so be aware of this and try to avoid ambiguity.
FAQs
alternative for regular expressions
We found that fsm-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.