
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.
sf-code-scanner
Advanced tools
A powerful Node.js CLI tool for scanning Salesforce Apex and LWC code for best practices and violations using PMD and custom rules.
Install Java using Homebrew (macOS):
brew install openjdk@17
Check java path:
which java
/opt/homebrew/opt/openjdk@17/bin/java
Download PMD from: https://pmd.github.io/
For macOS:
cd $HOME
curl -OL https://github.com/pmd/pmd/releases/download/pmd_releases%2F7.18.0/pmd-dist-7.18.0-bin.zip
unzip pmd-dist-7.18.0-bin.zip
alias pmd="$HOME/pmd-bin-7.18.0/bin/pmd"
pmd check -d /usr/src -R rulesets/java/quickstart.xml -f text
Node.js >= 14.0.0
Salesforce CLI (sf) installed and authenticated
PMD (Download from https://pmd.github.io/)
Active Salesforce org connection


npm install -g sf-code-scanner
sf-scan -u <username> -p <pmd-path> -s <scan-types> [options]
| Option | Alias | Required | Description |
|---|---|---|---|
--username | -u | Yes | Salesforce org username or alias |
--pmd-path | -p | Yes | Path to PMD binary directory |
--scan | -s | Yes | Types to scan: Apex, LWC, or both (comma-separated) |
--ruleset | -r | For Apex | Path to PMD ruleset file |
--output | -o | No | Output directory for reports (default: ./reports) |
sf-scan \
-u myorg@example.com \
-p /usr/local/pmd/bin \
-s Apex \
-r ./rulesets/apex-ruleset.xml
sf-scan \
-u myorg@example.com \
-p /usr/local/pmd/bin \
-s LWC
sf-scan \
-u myorg@example.com \
-p /usr/local/pmd/bin \
-s Apex,LWC \
-r ./rulesets/apex-ruleset.xml \
-o ./my-reports
Create a PMD ruleset XML file for Apex scanning. Example apex-ruleset.xml:
Download it from here:
<?xml version="1.0"?>
<ruleset name="Salesforce Apex Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Custom PMD Ruleset for Salesforce Apex</description>
<rule ref="category/apex/bestpractices.xml">
<priority>3</priority>
</rule>
<rule ref="category/apex/codestyle.xml">
<priority>4</priority>
</rule>
<rule ref="category/apex/design.xml">
<priority>3</priority>
</rule>
<rule ref="category/apex/errorprone.xml">
<priority>2</priority>
</rule>
<rule ref="category/apex/performance.xml">
<priority>2</priority>
</rule>
<rule ref="category/apex/security.xml">
<priority>1</priority>
</rule>
</ruleset>
The tool automatically checks for:
@api decorators on public properties@track usageThe generated HTML report includes:
reports/
├── scan-report-1234567890123.html
├── scan-report-1234567890456.html
└── ...
Ensure the PMD path points to the bin directory containing the pmd executable.
Authenticate using:
sf force auth web login -r <instance_url>
sf org display -o myorg --json
Verify org has Apex classes and user permissions.
Check ruleset XML validity and PMD compatibility.
Happy Scanning! 🚀
FAQs
Salesforce Code Scanner CLI for Apex and LWC best practices
We found that sf-code-scanner demonstrated a healthy version release cadence and project activity because the last version was released less than 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.