All Projects → leobenkel → Soteria

leobenkel / Soteria

Licence: MIT License
Plugin to block compilation when unapproved dependencies are used or code styling does not comply.

Programming Languages

scala
5932 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Soteria

H1domains
HackerOne "in scope" domains
Stars: ✭ 223 (+519.44%)
Mutual labels:  security-vulnerability, security-automation, security-tools
Network Threats Taxonomy
Machine Learning based Intrusion Detection Systems are difficult to evaluate due to a shortage of datasets representing accurately network traffic and their associated threats. In this project we attempt at solving this problem by presenting two taxonomies
Stars: ✭ 79 (+119.44%)
Mutual labels:  security-vulnerability, security-automation, security-tools
Vuls
Agent-less vulnerability scanner for Linux, FreeBSD, Container, WordPress, Programming language libraries, Network devices
Stars: ✭ 8,844 (+24466.67%)
Mutual labels:  security-vulnerability, security-automation, security-tools
Sbt Dependency Check
SBT Plugin for OWASP DependencyCheck. Monitor your dependencies and report if there are any publicly known vulnerabilities (e.g. CVEs). 🌈
Stars: ✭ 187 (+419.44%)
Mutual labels:  sbt, sbt-plugin, security-automation
sbt-project-switcher
A sbt plugin to switch project in a snappy way⚡️
Stars: ✭ 36 (+0%)
Mutual labels:  sbt, sbt-plugin
sbt-travisci
An sbt plugin to integrate with Travis CI
Stars: ✭ 44 (+22.22%)
Mutual labels:  sbt, sbt-plugin
sbt-hepek
Sbt plugin for rendering Scala objects to files. And more!
Stars: ✭ 17 (-52.78%)
Mutual labels:  sbt, sbt-plugin
chuckwagon
a Scala/sbt AWS Lambda Toolkit
Stars: ✭ 29 (-19.44%)
Mutual labels:  sbt, sbt-plugin
gatling-sbt-plugin
Gatling Plugin for SBT
Stars: ✭ 105 (+191.67%)
Mutual labels:  sbt, sbt-plugin
sbt-bazel
Easily convert SBT projects to Bazel workspaces
Stars: ✭ 55 (+52.78%)
Mutual labels:  sbt, sbt-plugin
sbt-flaky
Detect flaky tests with sbt
Stars: ✭ 35 (-2.78%)
Mutual labels:  sbt, sbt-plugin
NetworkAlarm
A tool to monitor local network traffic for possible security vulnerabilities. Warns user against possible nmap scans, Nikto scans, credentials sent in-the-clear, and shellshock attacks. Currently supports live monitoring and network capture (pcap) scanning.
Stars: ✭ 17 (-52.78%)
Mutual labels:  security-vulnerability, security-automation
sbt-rewarn
Make sbt always display compilation warnings, even for unchanged files.
Stars: ✭ 42 (+16.67%)
Mutual labels:  sbt, sbt-plugin
sbt-assembly
Deploy über-JARs. Restart processes. (port of codahale/assembly-sbt)
Stars: ✭ 1,801 (+4902.78%)
Mutual labels:  sbt, sbt-plugin
sbt-swagger-2
sbt plugin for generating Swagger JSON schemas during build
Stars: ✭ 13 (-63.89%)
Mutual labels:  sbt, sbt-plugin
xsbt-webstart
A Webstart plugin for sbt
Stars: ✭ 12 (-66.67%)
Mutual labels:  sbt, sbt-plugin
sbt-elm
Scala Build Tool (SBT) plugin for the Elm programming language
Stars: ✭ 44 (+22.22%)
Mutual labels:  sbt, sbt-plugin
sbt-kubeyml
Sbt plugin to help deploy Scala applications to Kubernetes
Stars: ✭ 37 (+2.78%)
Mutual labels:  sbt, sbt-plugin
sbt-publish-more
📤 Publish artifacts to more than one repository
Stars: ✭ 21 (-41.67%)
Mutual labels:  sbt, sbt-plugin
sbt-ecr
An SBT plugin for managing Docker images within Amazon ECR.
Stars: ✭ 52 (+44.44%)
Mutual labels:  sbt, sbt-plugin

Soteria_animated

License: MIT release-badge maven-central-badge BCH compliance Coverage Status Mutation testing badge

Soteria

Information about who was Soteria.

If you have any question submit an issue.

Table of Contents

Created by gh-md-toc

Presentations

Feel free to watch the talk given at Scala in the city (2020-05-28) with the slide deck.

Setup steps

  1. Make sure you are using SBT 1.2.x.
  2. Add to ./project/soteria.sbt in your project:
    addSbtPlugin("com.leobenkel" % "soteria" % soteriaVersion)
    
    The latest release is release-badge maven-central-badge
  3. Make sure to have a config file. Take a look at soteria.json for examples
  4. If you need a fat-jar:
    1. Add to your build.sbt the following lines:
      assemblyOption in assembly := soteriaAssemblySettings.value
      enablePlugins(DockerPlugin)
      
  5. Clean up your build.sbt by removing all pre-set settings:
    1. dependencyOverrides
    2. scalacOptions
    3. All settings related to sbt-assembly and sbt-docker
    4. All test options in Test:
      1. javaOptions in Test
      2. testOptions in Test
      3. parallelExecution in Test
      4. fork in Test
  6. Remove all plugins that are already included for you:
    1. sbt-scoverage
    2. sbt-assembly
    3. sbt-docker
    4. sbt-dependency-graph
    5. sbt-scalafix
    6. sbt-scalafmt
    7. scalastyle-sbt-plugin
  7. You can run your project the same as before. There can be compilation issues due to vulnerable dependencies.
  8. Dangerous! If you are not able to fix compiler issues, add: soteriaSoftOnCompilerWarning := true
  9. Dangerous! If you are not able to fix dependencies issues, add: soteriaSoft := true
  10. You can now then fix scala style issues:
    1. Run sbt soteriaCheckScalaStyle
    2. Run sbt soteriaCheckScalaFix
    3. Run sbt soteriaCheckScalaFmt
      1. If you are ready to rewrite the broken files:
        1. Create a clean branch
        2. Run sbt soteriaCheckScalaFmtRun

soteria.json

Root level

To override where the config file is read from, update the setting soteriaConfPath in your build.sbt. This setting can be a URL starting by http:// or https:// or a local file path. By default it will search for ./soteria.json.

Root level:

  • dockerImage: To set in which image the fat-jar will be built.
  • sbtVersion: SBTVersion to enforce. If a project is trying to compile with a different version, it will break.
  • scalaVersions: Is an array of authorized scala Version. This is an array and not a value to allow Spark/Play project on different version.
  • scalaCFlags: The list of compile flag to add to the build process. If soteriaSoftOnCompilerWarning is not true, then -Xfatal-warnings will be added as well to trigger a compilation failure.
  • modules: This is where the bulk of the settings are living.
    • The structure is groupId|com.organization -> artifactName -> description of the constraints

Modules

The modules are the constraint enforced by the plugin related to each dependencies.

The path to each module is groupId|com.organization -> artifactName -> description of the constraints.

A module can accept those keys:

  • version: Either None or a version number. If the library is added with a different version number, the compilation will fail
  • exactName: Default is True if absent. If false, the artifactName can just be a start. It is used for instance where you want to enforce a version for a library and related ones. circe or spark- can be good examples.
  • excludeName: Default empty. It is used to exclude libraries that would be catch by the name + exactName:false. It is used for instance in Play project where you would enforce something for all libraries starting by play- except a few that are behind on version numbers.
  • needDoublePercent: By default is false. If true, the conversion to sbt.ModuleID will be with %% instead of %. The same way it would be in the build.sbt.
  • shouldDownload: Is true by default and is only used for sbt soteriaGetAllDependencies.
  • overrideIsEnough: Default is true. This is related to dependenciesToRemove.
    • If overrideIsEnough is true, the library will be added to dependencyOverrides.
    • If overrideIsEnough is false, the library will be converted to an exclusion rule.
  • forbidden: Default is null. If this is set, and the library is added, the message will be displayed as a build failure. For instance you can use it to forbid one MySQL library and advise to use a different one.
  • shouldBeProvided: Default is false. If true, the compilation will fail if the library is not set to Provided in build.sbt. It is used for Spark.
  • dependenciesToRemove: This is a list of groupID | artifactName libraries to remove from this library. This is when overrideIsEnough come into play.
  • scalaVersionsFilter: This field is a list of scala versions, following this format: [+-][MajorVersion].[MinorVersion]<.[SmallVersion]>.

How to make sure library A is always version x.y and Provided ?

"modules": {
    "groupID.A": {
        "artifactName-A": {
            "version": "x.y",
            "shouldBeProvided": true
        }
    }
}

How to remove a dependency D completely from a library A ?

"modules": {
    "groupID.D": {
        "artifactName-D": {
            "version": "None",
            "overrideIsEnough": false
        }
    },
    "groupID.A": {
        "artifactName-A": {
            "dependenciesToRemove": [ 
                "groupID.D | artifactName-D"
            ],
            "version": "vA.A"
        }
    }
}

The dependenciesToRemove in A, will search for D. Since overrideIsEnough is false in D, the plugin will remove D from A using an ExclusionRule. Then, the plugin gather all the library which have been removed, and add them back with the appropriate version. In this case the version of D is None, so it will not be added back.

Is there an easy way to build the dependenciesToRemove tree ?

Yes there is !

First assemble your json:

"modules": {
   "groupID.D": {
       "artifactName-D": {
           "version": "None",
           "overrideIsEnough": false
       }
   },
   "groupID.A": {
       "artifactName-A": {
           "version": "vA.A"
       }
   },
   "groupID.B": {
       "artifactName-B": {
           "version": "vB.B"
       }
   }
}

Then run sbt soteriaDebugAllModules.

This will:

  1. Remove all the dependencies from your build.sbt
  2. List all the known libraries from your config file
  3. Add one library at a time, compile and get the fetched dependencies
  4. Compare the fetch dependencies with the known dependencies from your config file
  5. When all the libraries have been reviewed, the plugin will display a new json payload that you can just copy paste with all the dependenciesToRemove set to the knowledge you have in your json.

Features

Scala Style

The sbt plugin includes ScalaFix, ScalaStyle and ScalaFmt.

  1. Check that you have .scalafix.conf, .scalafmt.conf and scalastyle-config.xml in your project
    • Feel free to copy the one present in this repo to follow the same style guides
  2. Run sbt soteriaCheckScalaCheckAll to check that everything is correct.
    • You can run each system independently with:
      • sbt soteriaCheckScalaStyle
      • sbt soteriaCheckScalaFix
      • sbt soteriaCheckScalaFmt
  3. To apply the fix for ScalaFmt, you can run sbt soteriaCheckScalaFmtRun

Coveralls

Locally

You can run

sbt soteriaRunTestCoverage

to generate local reporting.

Just open:

./target/scala-2.xx/sbt-1.0/scoverage-report/index.html

Submit to coveralls

To submit to coveralls

sbt soteriaRunSubmitCoverage

This will generate the reports and submit it to coveralls using your COVERALLS token, set in the env var: COVERALLS_REPO_TOKEN.

For fat-jar assembly build

You need to add

assemblyOption in assembly := soteriaAssemblySettings.value
enablePlugins(DockerPlugin)

to your build.sbt file.

You can now call sbt docker to create the fat-jar. It will be located at ./target/docker/0/*.jar.

To change in which docker image the build is ran, you can change dockerImage in soteria.json.

!!!Dangerous!!! Allow compilation even with vulnerability

Vulnerability by-pass

By default, you won't be able to compile if you have errors in your build.

If you need time to fix several issues, you can add:

soteriaSoft := true

to your build.sbt file while you are fixing them.

Compilation warning by pass

If you also want to allow compiler warning, you will need to add:

soteriaSoftOnCompilerWarning := true

to your build.sbt file while you are fixing them

Debug

To print more or less logs for this plugin, you can set soteriaLogLevel.

For Debug:

soteriaLogLevel := Level.Debug

For Error only:

soteriaLogLevel := Level.Error

Publishing

  • Update version number in VERSION file.
  • Deploy the updated plugin locally: make publishLocal
  • Update version number in ./project/soteria.sbt.
  • Run the plugin on itself with make publishLocal
  • Publish: make publish

Authors

Leo Benkel

  • leobenkel-github-badge
  • leobenkel-linkedin-badge
  • leobenkel-personal-badge
  • leobenkel-patreon-badge
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].