
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
nsfw-filter
Advanced tools
npm i nsfw-filter
import NSFWFilter from 'nsfw-filter';
const isSafe = await NSFWFilter.isSafe(image);
import { useState } from 'react';
import NSFWFilter from 'nsfw-filter';
function ImageUploader() {
const [imageUrl, setImageUrl] = useState('');
const handleImageUpload = async (event) => {
const file = event.target.files[0];
// Check to see if the image is appropriate
const isSafe = await NSFWFilter.isSafe(file);
if (!isSafe) return 'Image is not appropriate';
// Process the image if it is safe
if (file) {
const reader = new FileReader();
reader.onloadend = () => {
setImageUrl(reader.result);
};
reader.readAsDataURL(file);
}
};
return (
<div>
<input type="file" onChange={handleImageUpload} />
{imageUrl && <img src={imageUrl} alt="Uploaded" />}
</div>
);
}
export default ImageUploader;
nsfw-filter
is currently used in production to process hundreds of thousands of images for a popular image restoration service called restorePhotos. It helps prevent people from uploading inappropriate pictures. See how it's used here.
you can polyfill the core node modules used in nsfw-filter for browser compatibility such as
["path", "stream", "assert", "events", "zlib", "util", "buffer"]
more on this: https://vitejs.dev/guide/troubleshooting.html
install vite-plugin-node-polyfills
with npm: https://www.npmjs.com/package/vite-plugin-node-polyfills
in vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { nodePolyfills } from "vite-plugin-node-polyfills";
import path from "path";
export default defineConfig({
plugins: [
nodePolyfills({
// To add only specific polyfills, add them here. If no option is passed, adds all polyfills
include: ["path", "stream", "assert", "events", "zlib", "util", "buffer"],
}),
react(),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"~": path.resolve(__dirname, "./"),
},
},
});
bonus: you can polyfill path to support path aliases for vite when you deploy your could on the cloud for example vercel.
so you can use @
import { cn } from "@/lib/utils"
disclaimer: using nsfw-filter on the browser will dramatically increase your bundle size.
This library uses both Tensorflow.js, an OSS library for machine learning models, and nsfwjs
to predict whether a given image is NSFW (Not Safe For Work).
FAQs
A minimal library that helps filter out NSFW images.
The npm package nsfw-filter receives a total of 38 weekly downloads. As such, nsfw-filter popularity was classified as not popular.
We found that nsfw-filter demonstrated a not healthy version release cadence and project activity because the last version was released 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.