
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@ministryofjustice/fb-transformers
Advanced tools
Component transformation functions with a CLI for Form Builder
Functions in this module transform Form Builder fileupload
components into upload
components and create any page.uploadCheck
or page.uploadSummary
steps, too.
Each of these functions return a Promise
. The promise can be resolved as part of a chain or using await
. (The examples below use await
syntax.)
All of these functions is exposed to the command line with Commander.
hasFileUploadComponentInForm
Accepts a path to a Form directory as an argument. It walks all the steps and standalone pages looking for fileupload
component and returns a boolean:
const directoryPath = '~/Documents/formbuilder/forms/ComponentFileUpload'
await hasFileUploadComponentInForm(directoryPath) // resolves to a boolean
transformFileUploadComponentsInForm
Accepts a path to a Form directory as an argument. It walks all the steps and standalone pages looking for fileupload
components and returns an array:
const directoryPath = '~/Documents/formbuilder/forms/ComponentFileUpload'
await transformFileUploadComponentsInForm(directoryPath) // resolves to an array of strings
The resolved array contains a list of all the files that were examined, not all the files that have been changed.
These functions are exported from the module and are used internally by the module.
hasFileUploadComponent
Accepts a path to a Form JSON file as an argument. It does not walk -- it is only interested in the properties of that Form step.
const filePath = '~/Documents/formbuilder/forms/ComponentFileUpload/metadata/page/page.fileupload.json'
await hasFileUploadComponent(filePath) // resolves to a boolean
hasUploadComponent
Accepts a path to a Form JSON file as an argument. As above, it does not walk.
const filePath = '~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json'
await hasUploadComponent(filePath) // resolves to a boolean
hasUploadCheckStep
Accepts a path to a Form JSON file as an argument. As above, it does not walk.
const filePath = '~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json'
await hasUploadCheckStep(filePath) // resolves to a boolean
hasUploadSummaryStep
Accepts a path to a Form JSON file as an argument. As above, it does not walk.
const filePath = '~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json'
await hasUploadCheckStep(filePath) // resolves to a boolean
These functions are exposed to the command line so that a developer can update a Form cloned to their environment, or run them from the shell in any other environment.
All of these flags should be prefaced with npm start --
. The double hyphen indicates that subsequent flags should be passed to the command. For example, assuming you have cloned a Form repository named ComponentFileUpload
to your environment:
npm start -- --has-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload
This will set the DEBUG
variable to enable logging in the terminal, and then execute the command:
node app --has-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload
Simply executing this on its own will invoke the functions silently, which is probably not what you want.
Each of these flags should be followed either by the path to a Form, or the path to a step JSON file.
Paths starting with the "~" character will be resolved to the user's home directory. (Paths containing whitespace should be provided in quotes.)
An error will be thrown if a path is not provided.
hasFileUploadComponentInForm
-h, --has-file-upload-in-form
String, path to FormDetermines whether Form has fileupload
component(s), invokes hasFileUploadComponentInForm
:
npm start -- --has-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload
transformFileUploadComponentsInForm
-t, --transform-file-upload-in-form
String, path to FormTransforms fileupload
component(s) in Form, invokes transformFileUploadComponentsInForm
:
npm start -- --transform-file-upload-in-form ~/Documents/formbuilder/forms/ComponentFileUpload
hasFileUploadComponent
--has-file-upload
String, path to stepDetermines whether step has fileupload
components(s), invokes hasFileUploadComponent
:
npm start -- --has-file-upload ~/Documents/formbuilder/forms/ComponentFileUpload/metadata/page/page.fileupload.json
transformFileUploadComponents
--transform-file-upload
String, path to stepTransforms fileupload
components(s) in step_, invokes transformFileUploadComponents
:
npm start -- --transform-file-upload ~/Documents/formbuilder/forms/ComponentFileUpload/metadata/page/page.fileupload.json
hasUploadComponent
--has-upload
String, path to stepDetermines whether step has upload
components(s), invokes hasUploadComponent
:
npm start -- --has-upload ~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json
hasUploadCheckStep
--has-upload-check
String, path to stepDetermines whether step has page.uploadCheck
step, invokes hasUploadCheckStep
:
npm start -- --has-upload-check ~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json
hasUploadSummaryStep
--has-upload-summary
String, path to stepDetermines whether step has page.uploadSummary
step, invokes hasUploadSummaryStep
:
npm start -- --has-upload-summary ~/Documents/formbuilder/forms/ComponentUpload/metadata/page/page.upload.json
FAQs
Component transformation functions with a CLI for Form Builder
The npm package @ministryofjustice/fb-transformers receives a total of 36 weekly downloads. As such, @ministryofjustice/fb-transformers popularity was classified as not popular.
We found that @ministryofjustice/fb-transformers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.