├── .gitignore ├── docs ├── .dockerignore ├── netlify.toml ├── src │ ├── pwa-512.png │ ├── components │ │ ├── images │ │ │ ├── day.png │ │ │ ├── night.png │ │ │ ├── closed.js │ │ │ ├── opened.js │ │ │ ├── help.svg │ │ │ ├── twitter-brands-block.svg │ │ │ ├── discord-brands-block.svg │ │ │ ├── twitter.svg │ │ │ ├── github.svg │ │ │ └── logo.svg │ │ ├── theme.js │ │ ├── mdxComponents │ │ │ ├── loading.js │ │ │ ├── anchor.js │ │ │ ├── LiveProvider.js │ │ │ ├── index.js │ │ │ └── codeBlock.js │ │ ├── index.js │ │ ├── search │ │ │ ├── styles.js │ │ │ ├── hitComps.js │ │ │ ├── input.js │ │ │ └── index.js │ │ ├── link.js │ │ ├── themeProvider.js │ │ ├── theme │ │ │ ├── index.js │ │ │ └── themeProvider.js │ │ ├── sidebar │ │ │ ├── treeNode.js │ │ │ ├── index.js │ │ │ └── tree.js │ │ ├── styles │ │ │ ├── Docs.js │ │ │ ├── Sidebar.js │ │ │ └── PageNavigationButtons.js │ │ ├── rightSidebar.js │ │ ├── DarkModeSwitch.js │ │ ├── layout.js │ │ └── NextPrevious.js │ ├── custom │ │ ├── styles │ │ │ └── styles.js │ │ └── config │ │ │ └── codeBlockLanguages.js │ ├── custom-sw-code.js │ ├── GithubLink.js │ ├── YoutubeEmbed.js │ ├── utils │ │ └── algolia.js │ ├── html.js │ └── templates │ │ └── docs.js ├── public │ ├── favicon.png │ └── images │ │ ├── ogp.png │ │ ├── sso.png │ │ ├── header.png │ │ ├── logo-white.png │ │ ├── about-us-screenshot.png │ │ └── twitter-brands-block.svg ├── content │ ├── images │ │ └── shisho-demo.gif │ ├── roadmap.md │ ├── index.md │ ├── shisho-action.md │ ├── shisho │ │ ├── learn-shisho.md │ │ ├── learn-shisho │ │ │ ├── 02-rule.md │ │ │ └── 01-pattern.md │ │ └── getting-started.md │ ├── shisho-dojo.md │ ├── changelog.md │ ├── shisho-cloud.md │ ├── shisho.md │ └── shisho-cloud │ │ ├── getting-started.md │ │ └── frequently-asked-questions.md ├── .prettierrc ├── .gitignore ├── .editorconfig ├── gatsby-browser.js ├── Dockerfile ├── .eslintrc.json ├── LICENSE ├── README.md ├── config.js ├── package.json ├── gatsby-node.js └── gatsby-config.js ├── src ├── cli │ ├── tests │ │ ├── mod.rs │ │ └── ruleset │ │ │ ├── generic │ │ │ ├── constraints │ │ │ │ ├── match.tf │ │ │ │ ├── unmatch.tf │ │ │ │ ├── match-pattern.yaml │ │ │ │ ├── not-match-pattern.yaml │ │ │ │ ├── not-match-regex-pattern.yaml │ │ │ │ ├── be-any-of.yaml │ │ │ │ ├── match-regex-pattern.yaml │ │ │ │ ├── match-any-of-regex-pattern.yaml │ │ │ │ ├── not-be-any-of.yaml │ │ │ │ ├── match-any-of-pattern.yaml │ │ │ │ ├── not-match-any-of-regex-pattern.yaml │ │ │ │ └── not-match-any-of-pattern.yaml │ │ │ ├── invalid_constraints │ │ │ │ ├── unmatch.tf │ │ │ │ ├── no-pattern-like.yaml │ │ │ │ ├── invalid-match-string.yaml │ │ │ │ ├── invalid-match-strings.yaml │ │ │ │ ├── ambiguous-pattern-use.yaml │ │ │ │ ├── mixed-pattern-like.yaml │ │ │ │ └── ambiguous-regex-pattern-use.yaml │ │ │ ├── nested_constraints │ │ │ │ ├── unmatch.without-inner.tf │ │ │ │ ├── unmatch.with-inner.tf │ │ │ │ ├── match.tf │ │ │ │ └── ruleset.yaml │ │ │ ├── encoding │ │ │ │ ├── utf_16le.go │ │ │ │ ├── shift_jis.go │ │ │ │ └── ruleset.yaml │ │ │ ├── shared_constraints │ │ │ │ ├── dockerfile │ │ │ │ ├── Dockerfile.test │ │ │ │ ├── test.Dockerfile │ │ │ │ └── ruleset.yaml │ │ │ └── mod.rs │ │ │ ├── hcl │ │ │ ├── comment │ │ │ │ ├── unmatch.tf │ │ │ │ ├── ruleset.yaml │ │ │ │ └── match.tf │ │ │ ├── unencrypted_ebs │ │ │ │ ├── unmatch.tf │ │ │ │ ├── match.tf │ │ │ │ └── ruleset.yaml │ │ │ ├── uncontrolled_ebs_encryption_key │ │ │ │ ├── match.tf │ │ │ │ ├── unmatch.tf │ │ │ │ └── ruleset.yaml │ │ │ └── mod.rs │ │ │ └── mod.rs │ ├── subcommand.rs │ ├── subcommand │ │ ├── completion.rs │ │ ├── find.rs │ │ └── check.rs │ ├── opts.rs │ ├── reporter.rs │ ├── reporter │ │ ├── json.rs │ │ └── sarif.rs │ └── encoding.rs ├── core │ ├── ruleset │ │ ├── assets │ │ │ ├── dumb │ │ │ ├── 1.yaml │ │ │ └── 2.yaml │ │ └── test.rs │ ├── matcher.rs │ ├── rewriter │ │ └── literal.rs │ ├── rewriter.rs │ ├── query.rs │ ├── matcher │ │ ├── state.rs │ │ └── literal.rs │ ├── language.rs │ ├── source.rs │ ├── pattern.rs │ └── tree.rs ├── lib.rs ├── core.rs ├── cli.rs └── main.rs ├── .vscode ├── extensions.json └── launch.json ├── rules └── docker.shisho.yaml ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── coverage.yml │ ├── test.yml │ └── release.yml ├── Dockerfile ├── .gitmodules ├── Cargo.toml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | .idea 3 | -------------------------------------------------------------------------------- /docs/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .cache 3 | -------------------------------------------------------------------------------- /src/cli/tests/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod ruleset; 3 | -------------------------------------------------------------------------------- /src/core/ruleset/assets/dumb: -------------------------------------------------------------------------------- 1 | this file should not be loaded -------------------------------------------------------------------------------- /docs/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | publish = "public" 3 | command = "npm run build" 4 | -------------------------------------------------------------------------------- /docs/src/pwa-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/src/pwa-512.png -------------------------------------------------------------------------------- /docs/public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/public/favicon.png -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/constraints/match.tf: -------------------------------------------------------------------------------- 1 | resource "block" "volume" { 2 | attr = 1 3 | } 4 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/constraints/unmatch.tf: -------------------------------------------------------------------------------- 1 | resource "block" "volume" { 2 | attr = 2 3 | } 4 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/hcl/comment/unmatch.tf: -------------------------------------------------------------------------------- 1 | resource "comment_test" "volume" { 2 | size = 1 3 | } 4 | -------------------------------------------------------------------------------- /docs/public/images/ogp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/public/images/ogp.png -------------------------------------------------------------------------------- /docs/public/images/sso.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/public/images/sso.png -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/invalid_constraints/unmatch.tf: -------------------------------------------------------------------------------- 1 | resource "block" "volume" { 2 | attr = 2 3 | } 4 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::or_fun_call, clippy::expect_fun_call)] 2 | 3 | pub mod cli; 4 | pub mod core; 5 | -------------------------------------------------------------------------------- /docs/public/images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/public/images/header.png -------------------------------------------------------------------------------- /docs/public/images/logo-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/public/images/logo-white.png -------------------------------------------------------------------------------- /docs/content/images/shisho-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/content/images/shisho-demo.gif -------------------------------------------------------------------------------- /docs/src/components/images/day.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/src/components/images/day.png -------------------------------------------------------------------------------- /docs/src/components/images/night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/src/components/images/night.png -------------------------------------------------------------------------------- /docs/public/images/about-us-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/docs/public/images/about-us-screenshot.png -------------------------------------------------------------------------------- /docs/src/components/theme.js: -------------------------------------------------------------------------------- 1 | export default { 2 | fonts: { 3 | mono: '"SF Mono", "Roboto Mono", Menlo, monospace', 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/nested_constraints/unmatch.without-inner.tf: -------------------------------------------------------------------------------- 1 | resource "block" "volume" { 2 | hoge = 1 3 | foo = 1 4 | } 5 | -------------------------------------------------------------------------------- /src/cli/subcommand.rs: -------------------------------------------------------------------------------- 1 | //! This module defines subcommands of `shisho` command. 2 | 3 | pub mod check; 4 | pub mod completion; 5 | pub mod find; 6 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/encoding/utf_16le.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/src/cli/tests/ruleset/generic/encoding/utf_16le.go -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/encoding/shift_jis.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flatt-security/shisho/HEAD/src/cli/tests/ruleset/generic/encoding/shift_jis.go -------------------------------------------------------------------------------- /docs/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "jsxBracketSameLine": false, 4 | "singleQuote": true, 5 | "tabWidth": 2, 6 | "trailingComma": "es5" 7 | } 8 | -------------------------------------------------------------------------------- /docs/src/custom/styles/styles.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react'; 2 | 3 | const customStyles = css` 4 | 5 | `; 6 | 7 | export const styles = [customStyles]; 8 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | .cache 2 | node_modules 3 | *DS_Store 4 | *.env 5 | 6 | .idea/ 7 | public/* 8 | !public/images/ 9 | !public/images/* 10 | !public/favicon.png 11 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/hcl/unencrypted_ebs/unmatch.tf: -------------------------------------------------------------------------------- 1 | resource "aws_ebs_volume" "volume" { 2 | availability_zone = "${var.region}a" 3 | size = 1 4 | encrypted = true 5 | } -------------------------------------------------------------------------------- /docs/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/nested_constraints/unmatch.with-inner.tf: -------------------------------------------------------------------------------- 1 | resource "block" "volume" { 2 | hoge = 1 3 | inner { 4 | a = 1 5 | b = 1 6 | } 7 | foo = 1 8 | } 9 | -------------------------------------------------------------------------------- /docs/src/custom-sw-code.js: -------------------------------------------------------------------------------- 1 | workbox.routing.registerRoute( 2 | new RegExp('https:.*min.(css|js)'), 3 | workbox.strategies.staleWhileRevalidate({ 4 | cacheName: 'cdn-cache', 5 | }) 6 | ); 7 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/nested_constraints/match.tf: -------------------------------------------------------------------------------- 1 | resource "block" "volume" { 2 | hoge = 1 3 | inner { 4 | a = 1 5 | test = 1 6 | b = 1 7 | } 8 | foo = 1 9 | } -------------------------------------------------------------------------------- /docs/src/components/mdxComponents/loading.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | const LoadingProvider = ({ ...props }) => { 4 | return
; 5 | }; 6 | 7 | export default LoadingProvider; 8 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/generic/encoding/ruleset.yaml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | rules: 3 | - id: "encoding" 4 | language: go 5 | message: | 6 | testing 7 | pattern: | 8 | fmt.Sprintf("abテストcd") 9 | -------------------------------------------------------------------------------- /src/core/matcher.rs: -------------------------------------------------------------------------------- 1 | mod item; 2 | pub use self::item::*; 3 | 4 | mod literal; 5 | pub use self::literal::*; 6 | 7 | mod state; 8 | pub use self::state::*; 9 | 10 | mod tree; 11 | pub use self::tree::*; 12 | -------------------------------------------------------------------------------- /src/core/ruleset/assets/1.yaml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | rules: 3 | - id: rule-01 4 | language: go 5 | message: | 6 | N/A 7 | pattern: | 8 | :[X] && :[X] 9 | rewrite: | 10 | :[X] 11 | -------------------------------------------------------------------------------- /src/core/ruleset/assets/2.yaml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | rules: 3 | - id: rule-02 4 | language: go 5 | message: | 6 | N/A 7 | pattern: | 8 | :[X] && :[X] 9 | rewrite: | 10 | :[X] 11 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "bungcip.better-toml", 4 | "vadimcn.vscode-lldb", 5 | "matklad.rust-analyzer", 6 | ], 7 | "unwantedRecommendations": [ 8 | "rust-lang.rust", 9 | ] 10 | } -------------------------------------------------------------------------------- /src/core.rs: -------------------------------------------------------------------------------- 1 | pub mod constraint; 2 | pub mod language; 3 | pub mod matcher; 4 | pub mod node; 5 | pub mod pattern; 6 | pub mod query; 7 | pub mod rewriter; 8 | pub mod ruleset; 9 | pub mod source; 10 | pub mod target; 11 | pub mod tree; 12 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/hcl/unencrypted_ebs/match.tf: -------------------------------------------------------------------------------- 1 | resource "aws_ebs_volume" "volume" { 2 | availability_zone = "${var.region}a" 3 | size = 1 4 | } 5 | 6 | resource "aws_ebs_volume" "volume" { 7 | availability_zone = "${var.region}a" 8 | size = 1 9 | } -------------------------------------------------------------------------------- /src/cli.rs: -------------------------------------------------------------------------------- 1 | //! This module includes some sub-modules to provide command-line interface of shisho. 2 | 3 | pub mod opts; 4 | pub use self::opts::*; 5 | 6 | pub mod reporter; 7 | pub mod subcommand; 8 | 9 | mod encoding; 10 | 11 | #[cfg(test)] 12 | mod tests; 13 | -------------------------------------------------------------------------------- /docs/gatsby-browser.js: -------------------------------------------------------------------------------- 1 | export const onServiceWorkerUpdateReady = () => { 2 | const answer = window.confirm( 3 | `This tutorial has been updated. ` + 4 | `Reload to display the latest version?` 5 | ) 6 | if (answer === true) { 7 | window.location.reload() 8 | } 9 | } -------------------------------------------------------------------------------- /docs/src/components/index.js: -------------------------------------------------------------------------------- 1 | export * from './theme'; 2 | import mdxComponents from './mdxComponents'; 3 | import ThemeProvider from './theme/themeProvider'; 4 | import Layout from './layout'; 5 | import Link from './link'; 6 | 7 | export {mdxComponents, ThemeProvider, Layout, Link} 8 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/hcl/uncontrolled_ebs_encryption_key/match.tf: -------------------------------------------------------------------------------- 1 | resource "aws_ebs_volume" "volume" { 2 | availability_zone = "${var.region}a" 3 | size = 1 4 | } 5 | 6 | resource "aws_ebs_volume" "volume" { 7 | availability_zone = "${var.region}a" 8 | size = 1 9 | } 10 | -------------------------------------------------------------------------------- /src/cli/tests/ruleset/hcl/comment/ruleset.yaml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | rules: 3 | - id: "test" 4 | language: hcl 5 | message: | 6 | test 7 | pattern: | 8 | resource "comment_test" :[NAME] { 9 | :[...] 10 | // hoge 11 | :[...] 12 | } 13 | -------------------------------------------------------------------------------- /rules/docker.shisho.yaml: -------------------------------------------------------------------------------- 1 | version: "1" 2 | rules: 3 | - id: no-latest-tag 4 | language: dockerfile 5 | message: | 6 | `latest` tag is used. Consider to use more concrete tag. 7 | patterns: 8 | - pattern: | 9 | FROM :[_]:latest 10 | - pattern: | 11 | FROM :[_]:latest as :[_] 12 | -------------------------------------------------------------------------------- /docs/src/components/images/closed.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const ClosedSvg = () => ( 4 | 7 | ); 8 | 9 | export default ClosedSvg; 10 | -------------------------------------------------------------------------------- /docs/src/components/images/opened.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const OpenedSvg = () => ( 4 | 7 | ); 8 | 9 | export default OpenedSvg; 10 | -------------------------------------------------------------------------------- /docs/src/components/search/styles.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Algolia } from '@styled-icons/fa-brands/Algolia'; 3 | 4 | export const PoweredBy = () => ( 5 | 6 | Powered by{` `} 7 | 8 |
20 |
21 | #### Shisho LP - 01/21/2022
22 |
23 | We updated some content with a new design.
24 |
25 | #### Shisho Cloud - 01/21/2022
26 |
27 | We released the new console UI.
28 |
29 | #### Shisho Cloud - 01/18/2022
30 |
31 | We released PR comment functions for [GitLab](https://about.gitlab.com/) and [BitBucket](https://bitbucket.org/product).
32 |
33 | #### Shisho Cloud - 01/14/2022
34 |
35 | We added new rules for [AWS](https://aws.amazon.com/), [GCP](https://cloud.google.com/) and [Azure](https://azure.microsoft.com/).
36 |
37 | #### Shisho Dojo - 12/18/2021
38 |
39 | We launched [SHisho Dojo](https://shisho.dev/dojo/).
40 |
41 | > Last Update: 01/28/2022
--------------------------------------------------------------------------------
/docs/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "eslint:recommended",
4 | "plugin:import/errors",
5 | "plugin:react/recommended",
6 | "plugin:jsx-a11y/recommended",
7 | "prettier",
8 | "prettier/react"
9 | ],
10 | "plugins": ["react", "import", "jsx-a11y"],
11 | "settings": {
12 | "react": {
13 | "version": "detect"
14 | }
15 | },
16 | "rules": {
17 | "react/prop-types": 0,
18 | "react/react-in-jsx-scope": "off",
19 | "lines-between-class-members": ["error", "always"],
20 | "padding-line-between-statements": [
21 | "error",
22 | { "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
23 | {
24 | "blankLine": "always",
25 | "prev": ["const", "let", "var"],
26 | "next": ["const", "let", "var"]
27 | },
28 | { "blankLine": "always", "prev": "directive", "next": "*" },
29 | { "blankLine": "any", "prev": "directive", "next": "directive" }
30 | ]
31 | },
32 | "parser": "babel-eslint",
33 | "parserOptions": {
34 | "ecmaVersion": 10,
35 | "sourceType": "module",
36 | "ecmaFeatures": {
37 | "jsx": true
38 | }
39 | },
40 | "env": {
41 | "es6": true,
42 | "browser": true,
43 | "node": true
44 | },
45 | "globals": {
46 | "graphql": false
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/cli/reporter.rs:
--------------------------------------------------------------------------------
1 | mod console;
2 | pub use self::console::*;
3 |
4 | mod json;
5 | pub use self::json::*;
6 |
7 | mod sarif;
8 | pub use self::sarif::*;
9 |
10 | use crate::core::{language::Queryable, matcher::MatchedItem, ruleset::Rule, target::Target};
11 | use anyhow::Result;
12 | use std::str::FromStr;
13 |
14 | pub trait Reporter<'a> {
15 | type Writer: std::io::Write;
16 | fn new(writer: &'a mut Self::Writer) -> Self
17 | where
18 | Self: Sized;
19 |
20 | fn add_entry
20 |
21 | ### 2. Select repository manager
22 |
23 | First of all, you need to select one of the repository connections. The currently supported services are:
24 |
25 | 1. [GitHub](https://github.com/)
26 | 2. [GitLab](https://about.gitlab.com/)
27 | 3. [BitBucket](https://bitbucket.org/product)
28 |
29 | > 📝 Tips: For [GitHub](https://github.com/) users, you need to install the Shisho GitHub App, which is one of the official "GitHub Apps". It supports integrating with [Shisho Cloud](https://shisho.dev/) and managing access permissions. If you have any questions, please check "Shisho GitHub App" on the page [Frequently asked questions](/shisho-cloud/frequently-asked-questions) for further details.
30 |
31 | ### 3. Select repository
32 |
33 | Please select a target repository that [Shisho Cloud](https://shisho.dev/) monitors your [Terrafrom](https://www.terraform.io/) code to maintain your healthy cloud resources. If you do not have [Terrafrom](https://www.terraform.io/) code OR you want to test [Shisho Cloud](https://shisho.dev/) without your own repositories, please folk and select a provided test repository. The [Terrafrom](https://www.terraform.io/) code in the test repository misconfigures [AWS](https://aws.amazon.com/) resources and policies for dummy resources on purpose. We assume it is enough to demonstrate the performance of [Shisho Cloud](https://shisho.dev/).
34 |
35 | > 📝 Tips: If you have some questions about the test repository, please check the section "Test repository [flatt-security/tfgoat-aws](https://github.com/flatt-security/tfgoat-aws)" on the page [Frequently asked questions](/shisho-cloud/frequently-asked-questions)
36 |
37 | That's all you have to do. Let's work and develop as usual with [Terrafrom](https://www.terraform.io/) code which is monitored by [Shisho Cloud](https://shisho.dev/)!
38 |
39 | ## Do you have any questions?
40 |
41 | Please check the page [Frequently asked questions](/shisho-cloud/frequently-asked-questions)
42 |
43 |
--------------------------------------------------------------------------------
/src/cli/tests/ruleset/generic/mod.rs:
--------------------------------------------------------------------------------
1 | #[cfg(test)]
2 | mod tests {
3 | ruleset_test! {
4 | encoding: [
5 | ("ruleset.yaml", "shift_jis.go", Result::Ok(3), Some(encoding_rs::SHIFT_JIS)),
6 | ("ruleset.yaml", "utf_16le.go", Result::Ok(3), Some(encoding_rs::UTF_16LE)),
7 | ],
8 | nested_constraints: [
9 | ("ruleset.yaml", "match.tf", Result::Ok(1), None),
10 | ("ruleset.yaml", "unmatch.with-inner.tf", Result::Ok(0), None),
11 | ("ruleset.yaml", "unmatch.without-inner.tf", Result::Ok(0), None),
12 | ],
13 | constraints: [
14 | ("be-any-of.yaml", "match.tf", Result::Ok(1), None),
15 | ("be-any-of.yaml", "unmatch.tf", Result::Ok(0), None),
16 | ("not-be-any-of.yaml", "match.tf", Result::Ok(1), None),
17 | ("not-be-any-of.yaml", "unmatch.tf", Result::Ok(0), None),
18 |
19 | ("match-pattern.yaml", "match.tf", Result::Ok(1), None),
20 | ("match-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
21 | ("not-match-pattern.yaml", "match.tf", Result::Ok(1), None),
22 | ("not-match-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
23 |
24 | ("match-regex-pattern.yaml", "match.tf", Result::Ok(1), None),
25 | ("match-regex-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
26 | ("not-match-regex-pattern.yaml", "match.tf", Result::Ok(1), None),
27 | ("not-match-regex-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
28 |
29 | ("match-any-of-pattern.yaml", "match.tf", Result::Ok(1), None),
30 | ("match-any-of-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
31 | ("not-match-any-of-pattern.yaml", "match.tf", Result::Ok(1), None),
32 | ("not-match-any-of-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
33 |
34 | ("match-any-of-regex-pattern.yaml", "match.tf", Result::Ok(1), None),
35 | ("match-any-of-regex-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
36 | ("not-match-any-of-regex-pattern.yaml", "match.tf", Result::Ok(1), None),
37 | ("not-match-any-of-regex-pattern.yaml", "unmatch.tf", Result::Ok(0), None),
38 | ],
39 | invalid_constraints: [
40 | ("invalid-match-string.yaml", "unmatch.tf", Result::Err(anyhow::anyhow!("")), None),
41 | ("invalid-match-strings.yaml", "unmatch.tf", Result::Err(anyhow::anyhow!("")), None),
42 |
43 | ("ambiguous-pattern-use.yaml", "unmatch.tf", Result::Err(anyhow::anyhow!("")), None),
44 | ("ambiguous-regex-pattern-use.yaml", "unmatch.tf", Result::Err(anyhow::anyhow!("")), None),
45 |
46 | ("mixed-pattern-like.yaml", "unmatch.tf", Result::Err(anyhow::anyhow!("")), None),
47 | ("no-pattern-like.yaml", "unmatch.tf", Result::Err(anyhow::anyhow!("")), None),
48 | ],
49 | shared_constraints: [
50 | ("ruleset.yaml", "test.Dockerfile", Result::Ok(8), None),
51 | ("ruleset.yaml", "dockerfile", Result::Ok(8), None),
52 | ("ruleset.yaml", "Dockerfile.test", Result::Ok(8), None),
53 | ],
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # shisho
2 |
3 | 
4 |
5 | [![GitHub Release][release-img]][release]
6 | [![GitHub Marketplace][marketplace-img]][marketplace]
7 | [![License][license-img]][license]
8 | [![Documentation][documentation-img]][documentation]
9 | [![Test][test-img]][test]
10 | [![Playground][playground-img]][playground]
11 |
12 | Shisho is a lightweight static analyzer for developers.
13 |
14 | ### Please see [the usage documentation](https://docs.shisho.dev) for further information.
15 |
16 | 
17 |
18 | ## Try at Playground
19 |
20 | You can try Shisho at [our playground](https://play.shisho.dev).
21 |
22 | ## Try with Docker
23 |
24 | You can try shisho in your machine as follows:
25 |
26 | ```sh
27 | echo "func test(v []string) int { return len(v) + 1; }" | docker run -i ghcr.io/flatt-security/shisho-cli:latest find "len(:[...])" --lang=go
28 | ```
29 |
30 | ```sh
31 | echo "func test(v []string) int { return len(v) + 1; }" > file.go
32 | docker run -i -v $(pwd):/workspace ghcr.io/flatt-security/shisho-cli:latest find "len(:[...])" --lang=go /workspace/file.go
33 | ```
34 |
35 | ## Install with pre-built binaries
36 |
37 | When you'd like to run shisho outside docker containers, please follow the instructions below:
38 |
39 | ### Linux / macOS
40 |
41 | Run the following command(s):
42 |
43 | ```sh
44 | # Linux
45 | wget https://github.com/flatt-security/shisho/releases/latest/download/build-x86_64-unknown-linux-gnu.zip -O shisho.zip
46 | unzip shisho.zip
47 | chmod +x ./shisho
48 | mv ./shisho /usr/local/bin/shisho
49 |
50 | # macOS
51 | wget https://github.com/flatt-security/shisho/releases/latest/download/build-x86_64-apple-darwin.zip -O shisho.zip
52 | unzip shisho.zip
53 | chmod +x ./shisho
54 | mv ./shisho /usr/local/bin/shisho
55 | ```
56 |
57 | Then you'll see a shisho's executable in `/usr/local/bin`.
58 |
59 | ### Windows
60 |
61 | Download the prebuild binary from [releases](https://github.com/flatt-security/shisho/releases) and put it into your `%PATH%` directory.
62 |
63 | If you're using [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10), you can install shisho with the above instructions.
64 |
65 | # More
66 |
67 | - We're also building [Shisho as a Service](https://shisho.dev) to make Security-as-Code more accessible.
68 | - If you need direct support, you can contact us at `contact@flatt.tech`.
69 |
70 | [release]: https://github.com/flatt-security/shisho/releases/latest
71 | [release-img]: https://img.shields.io/github/release/flatt-security/shisho.svg?logo=github
72 | [marketplace]: https://github.com/marketplace/actions/shisho-action
73 | [marketplace-img]: https://img.shields.io/badge/marketplace-shisho--action-blue?logo=github
74 | [license]: https://github.com/flatt-security/shisho/blob/main/LICENSE
75 | [license-img]: https://img.shields.io/github/license/flatt-security/shisho
76 | [documentation]: https://docs.shisho.dev
77 | [documentation-img]: https://img.shields.io/badge/docs-docs.shisho.dev-purple
78 | [playground]: https://play.shisho.dev
79 | [playground-img]: https://img.shields.io/badge/playground-playground.shisho.dev-purple
80 | [test]: https://github.com/flatt-security/shisho/actions/workflows/test.yml
81 | [test-img]: https://github.com/flatt-security/shisho/actions/workflows/test.yml/badge.svg?branch=main
82 |
--------------------------------------------------------------------------------
/src/core/pattern.rs:
--------------------------------------------------------------------------------
1 | use super::{
2 | constraint::Constraint, language::Queryable, node::RootNode,
3 | ruleset::RawPatternWithConstraints, source::NormalizedSource,
4 | };
5 | use anyhow::{anyhow, Result};
6 | use std::{
7 | convert::{TryFrom, TryInto},
8 | marker::PhantomData,
9 | };
10 |
11 | #[derive(Debug)]
12 | pub struct Pattern
50 | {cleanTokens(tokens).map((line, i) => {
51 | let lineClass = {};
52 |
53 | let isDiff = false;
54 |
55 | if (line[0] && line[0].content.length && line[0].content[0] === '+') {
56 | lineClass = { backgroundColor: 'rgba(76, 175, 80, 0.2)' };
57 | isDiff = true;
58 | } else if (line[0] && line[0].content.length && line[0].content[0] === '-') {
59 | lineClass = { backgroundColor: 'rgba(244, 67, 54, 0.2)' };
60 | isDiff = true;
61 | } else if (line[0] && line[0].content === '' && line[1] && line[1].content === '+') {
62 | lineClass = { backgroundColor: 'rgba(76, 175, 80, 0.2)' };
63 | isDiff = true;
64 | } else if (line[0] && line[0].content === '' && line[1] && line[1].content === '-') {
65 | lineClass = { backgroundColor: 'rgba(244, 67, 54, 0.2)' };
66 | isDiff = true;
67 | }
68 | const lineProps = getLineProps({ line, key: i });
69 |
70 | lineProps.style = lineClass;
71 | const diffStyle = {
72 | userSelect: 'none',
73 | MozUserSelect: '-moz-none',
74 | WebkitUserSelect: 'none',
75 | };
76 |
77 | let splitToken;
78 |
79 | return (
80 |
81 | {line.map((token, key) => {
82 | if (isDiff) {
83 | if (
84 | (key === 0 || key === 1) &
85 | (token.content.charAt(0) === '+' || token.content.charAt(0) === '-')
86 | ) {
87 | if (token.content.length > 1) {
88 | splitToken = {
89 | types: ['template-string', 'string'],
90 | content: token.content.slice(1),
91 | };
92 | const firstChar = {
93 | types: ['operator'],
94 | content: token.content.charAt(0),
95 | };
96 |
97 | return (
98 |
99 |
103 |
104 |
105 | );
106 | } else {
107 | return ;
108 | }
109 | }
110 | }
111 | return ;
112 | })}
113 |
114 | );
115 | })}
116 |
117 | )}
118 |