All Projects → anordal → Shellharden

anordal / Shellharden

Licence: mpl-2.0
The corrective bash syntax highlighter

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to Shellharden

elint
A easy way to lint your code
Stars: ✭ 38 (-99.08%)
Mutual labels:  lint
Flask Api Starter Kit
Start a Flask API in less than 5 minutes
Stars: ✭ 296 (-92.86%)
Mutual labels:  lint
Irods
Open Source Data Management Software
Stars: ✭ 321 (-92.26%)
Mutual labels:  policy
gandalf-lint
Bad Code Shall Not Pass
Stars: ✭ 29 (-99.3%)
Mutual labels:  lint
Okcheck
Incremental scan,integrate Lint、KtLint、UnitTest、Checkstyle、Findbugs、Pmd, powerful and easy to use
Stars: ✭ 285 (-93.13%)
Mutual labels:  lint
Reviewdog
🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
Stars: ✭ 4,541 (+9.5%)
Mutual labels:  lint
selective
Statically find HTML anti patterns using CSS Selectors
Stars: ✭ 15 (-99.64%)
Mutual labels:  lint
K Rail
Kubernetes security tool for policy enforcement
Stars: ✭ 350 (-91.56%)
Mutual labels:  policy
Sketch Lint
Check the compliance of your design guidelines within seconds
Stars: ✭ 291 (-92.98%)
Mutual labels:  lint
Policy Bot
A GitHub App that enforces approval policies on pull requests
Stars: ✭ 297 (-92.84%)
Mutual labels:  policy
knuckle
Project configuration handler, without efforts
Stars: ✭ 14 (-99.66%)
Mutual labels:  lint
Gradle Code Quality Tools Plugin
Gradle plugin that generates ErrorProne, Findbugs, Checkstyle, PMD, CPD, Lint, Detekt & Ktlint Tasks for every subproject.
Stars: ✭ 282 (-93.2%)
Mutual labels:  lint
Eslint Plugin Import
ESLint plugin with rules that help validate proper imports.
Stars: ✭ 3,722 (-10.25%)
Mutual labels:  lint
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.
Stars: ✭ 19 (-99.54%)
Mutual labels:  lint
Trumptracker.github.io
Open source for http://trumptracker.github.io/
Stars: ✭ 338 (-91.85%)
Mutual labels:  policy
policy-data-analyzer
Building a model to recognize incentives for landscape restoration in environmental policies from Latin America, the US and India. Bringing NLP to the world of policy analysis through an extensible framework that includes scraping, preprocessing, active learning and text analysis pipelines.
Stars: ✭ 22 (-99.47%)
Mutual labels:  policy
Hint
💡 A hinting engine for the web
Stars: ✭ 3,280 (-20.91%)
Mutual labels:  lint
Detekt
Static code analysis for Kotlin
Stars: ✭ 4,169 (+0.53%)
Mutual labels:  lint
Exakat
The Exakat Engine : smart static analysis for PHP
Stars: ✭ 346 (-91.66%)
Mutual labels:  lint
Coala
coala provides a unified command-line interface for linting and fixing all your code, regardless of the programming languages you use.
Stars: ✭ 3,280 (-20.91%)
Mutual labels:  lint

Build and test status

Shellharden

Shellharden is a syntax highlighter and a tool to semi-automate the rewriting of scripts to ShellCheck conformance, mainly focused on quoting.

The default mode of operation is like cat, but with syntax highlighting in foreground colors and suggestive changes in background colors:

real-world example

Above: Selected portions of xdg-desktop-menu as highlighted by Shellharden. The foreground colors are syntax highlighting, whereas the background colors (green and red) show characters that Shellharden would have added or removed if let loose with the --transform option. Below: An artificial example that shows more tricky cases and special features.

artificial example

Why

A variable in bash is like a hand grenade – take off its quotes, and it starts ticking. Hence, rule zero of bash pitfalls: Always use quotes.

Name

Shellharden can do what Shellcheck can't: Apply the suggested changes.

In other words, harden vulnerable shellscripts. The builtin assumption is that the script does not depend on the vulnerable behavior – the user is responsible for the code review.

Shellharden was previously known as "Naziquote". In the right jargon, that was the best name ever, but oh so misleading and unspeakable to outsiders.

I couldn't call it "bash cleaner" either, as that means "poo smearer" in Norwegian.

Prior art

  • Shellcheck is a wonderful tool to detect, and give general advice, about vulnerable bash code. The only thing missing is something to say yes with, and apply those advice (assuming proper review of course).

  • I asked this SO question, for a tool that could rewrite bash scripts with proper quoting. One answerer beat me to it. But if it was me, I would do a syntax highlighter in the same tool (as a way to see if the parser gets lost, and make the most out of the parser, because bash is like quantum mechanics – nobody really knows how it works).

Get it

Distro packages:

Packaging status

Official rust package:

cargo install shellharden

For those allergic to building from source, a few precompiled binaries are also available in the releases.

Build from source

cargo build --release

Run tests

cargo test --release

(requires bash)

Install

cp target/release/shellharden /usr/local/bin/

Fuzz test

cargo install afl
cargo afl build --release
cargo afl fuzz -i moduletests/original -o /tmp/fuzz-shellharden target/release/shellharden '@@'

Usage advice

Don't apply --transform blindly; code review is still necessary: A script that relies on unquoted behavior (implicit word splitting and glob expansion from variables and command substitutions) to work as intended will do none of that after getting the --transform treatment!

In that unlucky case, ask yourself whether the script has any business in doing that. All too often, it's just a product of classical shellscripting, and would be better off rewritten, such as by using arrays. Even in the opposite case, say the business logic involves word splitting; that can still be done without invoking globbing. In short: There is always a better way than the forbidden syntax (if not more explicit), but some times, a human must step in to rewrite. See how, in the accompanying how to do things safely in bash.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].