Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
postcss-finding-dead-css
Advanced tools
PostCSS plugin that help identifying the dead code. Idea. Only my plugin uses only the css border-image property.
# the plugin
yarn add -D postcss-finding-dead-css
#or npm install --save-dev postcss-finding-dead-css
body {
margin: 0;
}
.alredy-use-border-image {
border-image: linear-gradient(red, yellow) 10;
}
body {
margin: 0;
border-image-source: url('/cssdead?data=%7B%22selector%22:%22body%22,%22startLine%22:1,%22startColumn%22:1%7D&file=/home/mur/github/postcss-finding-dead-css/example/readme/input.css');
}
.alredy-use-border-image {
border-image: linear-gradient(red, yellow) 10;
}
// Node.js 8.x
const { readFileSync, writeFileSync } = require("fs");
const { resolve } = require("path");
const postcss = require("postcss");
const postcssDeadCss = require("postcss-finding-dead-css");
const [from, to] = ["./input.css", "./output.css"].map(f =>
resolve(__dirname, f)
);
const CSS = readFileSync(from);
const PLUGINS = [
postcssDeadCss({
// deadApiUrl: "http://my-analytic.server.com/cssdead", // default '/cssdead'
// url({selector, startLine, startColumn, file}) { // custom url
// return encodeURI(
// `${this.deadApiUrl}?data=${JSON.stringify({
// selector,
// startLine,
// startColumn
// })}&file=${file}`
// );
// }
})
];
(async () => {
try {
const { css, messages } = await postcss(PLUGINS).process(CSS, { from, to });
messages
.filter(({ type }) => type === "warning")
.map(msg => console.log(msg.toString()));
console.log(css);
writeFileSync(to, css);
} catch (e) {
console.error(e);
}
})();
deadApiUrl
, type: String
, required: false
default: '/cssdead'
Url to back-end api, I send two parametrs type
and file
type
- has json { selector, startLine, startColumn }
file
- path to source css file
url
, type: Function
, required: false
This function help you customize url generation
// Node.js 8.x
// example get middlewares:
const {getMiddleware} = require('postcss-finding-dead-css');
const {middlewareCheckDead, middlewareStat} = getMiddleware(options);
// Express.js
const app = express();
app.get(options.deadApiUrl, middlewareCheckDead);
{
deadApiUrl: '/custom/path', // defualt: '/cssdead'
statApiUrl: '/custom/path/stat' // defualt: '/getStat'
}
FAQs
PostCSS plugin that help identifying the dead code
The npm package postcss-finding-dead-css receives a total of 2 weekly downloads. As such, postcss-finding-dead-css popularity was classified as not popular.
We found that postcss-finding-dead-css 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.