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.
Serialize css structure and stringify css dom, simplified change css code by program, and also support uglify and beautify
var CssDom = require('cssdom');
npm install cssdom --save
npm test
Exports cssdom to front
browserify cssdom.js -s CssDom > cssdom.front.js
http://douzi8.github.io/cssdom/
str
requiredvar css = new CssDom('a{}');
The structure of css dom, it's an array with object item, list item type
charset
// @charset 'utf8';
{
type: 'charset',
value: 'utf8'
}
import
// @import 'custom.css';
{
type: 'import',
value: "'custom.css'"
}
rule
// .a { color: #333;}
{
type: 'rule',
selectors: ['.a'],
declarations: {
color: '#333'
}
}
keyframes
// @-webkit-keyframes progress-bar-stripes{}
{
type: 'keyframes',
vendor: '-webkit-',
value: 'progress-bar-stripes',
rules: [
// It's rule type
...
]
}
document
{
type: 'document',
vendor: '-moz-',
value: 'url-prefix()',
rules: [
// It's rule type
...
]
}
media
// @media print {body { font-size: 10pt }}
{
type: 'media',
value: 'print',
rules: [
// It's rule type
...
]
}
supports
// @supports (display: flex) {}
{
type: 'supports',
value: '(display: flex)',
rules: [
// It's rule type
...
]
}
comment
// /*1*/
{
type: 'comment',
value: '1'
}
Change css declarations
dom
requiredcss
requiredcss.css(css.dom[0], {
'color': 'red'
});
Change css by selector, if css is empty, it will return css dom
selector
requiredcss
css.selector('.cls', {
width: '200px',
height: function(value, dom) {
// value -> origin value
// dom -> current css dom
return value;
},
// delete color key
color: ''
});
css.selector('.cls');
Change css by property
selector
requiredcss
requiredcss.property('background', {
background: function(value) {
return value;
}
});
var child = css.property('background');
child.forEach(function(dom) {
css.css(dom, {
background: function(value) {
return value.replce(/url\(('[^']*'|"[^"]*"|[^)]*)\)/, function(src) {
return src;
});
}
});
});
dom
requiredcss.unshift({
type: 'comment',
value: 'banner'
});
dom
requiredcss.push({
type: 'rule',
selectors: ['a'],
declarations: {
color: '#333',
'line-height': '20px'
}
});
dom
requiredcss.validateDom({});
css.validateDom([{}]);
Uglify css code.
it will remove all comment, if you want to keep some comment, your comments will start with /*!
/*!
* keep this comment
*/
css.stringify();
Beautify css code
FAQs
Serialize css structure and stringify css dom, simplified change css code by program, and also support uglify and beautify
The npm package cssdom receives a total of 8 weekly downloads. As such, cssdom popularity was classified as not popular.
We found that cssdom 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.