
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@ospin/fct-graph
Advanced tools
Graph data structure with conditional edges via 'slots' on nodes. Intended to represent physical and virtual functionalities on a device.
This documentation is likely to remain sparse, as it is for internal use and under development!
The FCTGraph functions like a traditional graph with several features on top. Most importantly, all functionalities (nodes) have many slots, which hold data about themselves. Slots connect to other slots (if they are compatible) via dataStreams (edges).
The following is a selected showcase of the public functions on the various base objects of:
const { FCTGraph, functionalities, slots } = require('@ospin/FCTGraph') // or import
// first, let's set up some seed data. Functionalities (nodes) have many dataStreams (edges)...
const tempOutSlotData = { name: 'temp out', type: 'OutSlot', ... } /* see OutSlot.SCHEMA */
const tempSensorData = { slots: [ tempOutSlotData ], ... } /* see TemperatureSensor.SCHEMA */
const tempInSlotData = { name: 'temp in', type: 'InSlot', ... } /* see InSlot.SCHEMA */
const pidControllerData = { slots: [ tempInSlotData ], ... } /* see PIDController.SCHEMA */
// ...and instantiate our FCTGraph
const fctGraph = new FCTGraph({
functionalities: [ tempSensorData, pidControllerData ],
...,
}) /* see FCTGraph.SCHEMA */)
// we can also add functionalities after the fact
fctGraph.addFunctionality({ ...heaterActuatorData })
fctGraph.functionalities
// -> a temperature sensor with a temperature outslot
// -> a PID controller with a temperature in slot
// -> a heater actuator
// ...continuing from above. let's connect the temperature sensor to the PIDController
const [ tempSensor, pidController, heaterActuator ] = fctGraph.functionalities
const { slots: [ tempOutSlot, ... ] } = tempSensor
const { slots: pidControllerSlots } = pidController
// get those slots on the PIDController which are connectable to the temperature sensor
const [ connectableSlot, ... ] = tempOutSlot.filterConnectableSlots(pidControllerSlots)
// connect!
const { dataStream } = tempOutSlot.addConnectionTo(connectableSlot)
// -> dataStream { id, sourceSlotName: 'temp out', sinkSlotName: 'temp in', ... }
// ...continuing from above
tempSensor.isPossibleToConnectToFct(pidController)
// -> true
fctGraph.getConnectableFctsToTargetFct(pidController)
// -> [ tempSensor, ... ]
// Graph mutating public methods return a standard response object:
// response object: { error: <bool>, errorMsg: <string>, ...relevantData }
const goodFctData = /* valid data for a new functionality */
const { error, errorMsg, functionality } = fctGraph.addFunctionality(fctData)
console.log(error) // -> false
console.log(errorMsg) // -> null
console.log(functionality instanceof Functionality) // -> null
fctGraph.serialize()
// -> returns the nested data object (no instances)
const fctGraphJSON = JSON.stringify(fctGraph)
// -> returns valid JSON with no information lost
const fctGraphClone = FCTGraph.new(JSON.parse(fctGraphJSON))
// -> works!
Where appropriate (and hopefully whenever this package is extended) public methods which mutate instances in a major way (e.g. adding functionalities to the graph, connecting slots, etc.) return a response object. Response objects are intended to be useful in cases where a caller attempts to mutate the FCTGraph (or a portion of it) in a way that would ultimately fail data validation. The response objects will return actionable information for the caller.
const failure = fctGraph.addFunctionality({ name: 123, ...validData })
// {
// error: true,
// errorMsg: 'Failed to add fct: <fct data>. Underlying error: name must be a string',
// functionality: <{ ...the failed functionalities data }>,
// }
const success = fctGraph.addFunctionality({ name: 'Dr. Strangelove\'s Bunker Heater', ...validData })
// {
// error: false,
// errorMsg: null,
// functionality: <the added functionality>,
// }
FCTGraph
// an FCTGraph has many Functionalities
Functionality (virtual)
├── Actuator (virtual)
│ └── HeaterActuator
├── Controller (virtual)
│ └── PIDController
├── InputNode (virtual)
│ └── PushIn
├── OutputNode (virtual)
│ ├── PushOut
│ └── IntervalOut
└── Sensor (virtual)
└── TemperatureSensor
// a Functionality has many Slots
Slot (virtual)
├── InSlot (virtual)
│ └── IntegerInSlot
│ └── FloatInSlot
│ └── BooleanInSlot
│ └── OneOfInSlot
└── OutSlot
// a Slot has many DataStreams
DataStream
All non-virtual classes (e.g. HeaterActuator, InSlot, etc.) compose the JOIous module, which provides the following:
.serialize
methodFunctionalities and Slots need somewhat intelligent instantiation as they are meant to be serialized to and from JSON. For this reason, Factories exist for instantiating both Functionalities and Slots. Instantiating an FCTGraph from parsed JSON will automatically delegate to the factories as it builds the hierarchy.
FCTGraph delegates to the FunctionalityFactory when functionalities are added. The factory will attempt to find the appropriate functionality sub-class via the type
and subType
key values and blow up if it can not find one.
Functionality delegates to the SlotFactory when slots are added. The factory will attempt to find the appropriate slot sub-class via the type
key value and blow up if it can not find one.
Functionalities and Slots can also be created directly calling the constructors on their non-virtual classes. See Class Structure and Hierarchies
NOTE: Seeders are meant for testing purposes ONLY. While they carry a high test coverage %, they (likely) don't have the 100% Green™ coverage that the rest does.
The package comes with seeders which have the same class hierarchy as the primary models:
FCTGraphSeeder
FunctionalitySeeder (virtual)
├── ActuatorSeeder (virtual)
│ ├── HeaterActuatorSeeder
│ └── UnknownActuatorSeeder
├── ControllerSeeder (virtual)
│ └── PIDControllerSeeder
├── InputNodeSeeder (virtual)
│ └── PushInSeeder
├── OutputNodeSeeder (virtual)
│ ├── PushOutSeeder
│ └── IntervalOutSeeder
└── SensorSeeder (virtual)
├── TemperatureSensorSeeder
└── UnknownSensorSeeder
SlotSeeder (virtual)
├── InSlotSeeder (virtual)
│ └── IntegerInSlotSeeder
│ └── FloatInSlotSeeder
│ └── BooleanInSlotSeeder
│ └── OneOfInSlotSeeder
└── OutSlotSeeder
All virtual seeders (e.g. HeaterActuatorSeeder, InSlotSeeder etc.) compose the FactorySeeder module, which provides the following static methods (which extend to their children):
.SEED_METHOD
getter. This method should used to call a constructor/factory's creation method.generate
method. This method should be used to create fake data which matches the class SCHEMAgenerate
and SEED_METHOD
This repo employs the github action semantic-release, which, on approved PRs to main
, sniffs the PR title/commit message to automatically bump the semantic versioning and publish the package to NPM.
All PRs to the main
branch should indicate the semantic version change via the following options:
Available types:
type
, subType
, name
, etc.)FAQs
Graph data structure with conditional edges via 'slots' on nodes. Intended to represent physical and virtual functionalities on a device.
The npm package @ospin/fct-graph receives a total of 0 weekly downloads. As such, @ospin/fct-graph popularity was classified as not popular.
We found that @ospin/fct-graph demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.