Git Product home page Git Product logo

fossas / fossa-cli Goto Github PK

View Code? Open in Web Editor NEW
1.2K 40.0 171.0 113.56 MB

Fast, portable and reliable dependency analysis for any codebase. Supports license & vulnerability scanning for large monoliths. Language-agnostic; integrates with 20+ build systems.

Home Page: https://fossa.com

License: Mozilla Public License 2.0

Makefile 0.19% Shell 1.25% Python 0.04% PowerShell 0.24% Haskell 93.86% Nix 0.03% Rust 4.40%
open-source-licensing open-source-vulnerabilities

fossa-cli's Introduction

FOSSA

FOSSA CLI

FOSSA Downloads Build Dependency scan FOSSA Security Status

FOSSA Status

fossa-cli is a zero-configuration polyglot dependency analysis tool. You can point fossa CLI at any codebase or build, and it will automatically detect dependencies being used by your project.

fossa-cli currently supports automatic dependency analysis for many different build tools and languages. It also has limited support for vendored dependency detection, container scanning, and system dependency detection. These features are still a work in progress. Our goal is to make the FOSSA CLI a universal tool for dependency analysis.

fossa-cli integrates with FOSSA for dependency analysis, license scanning, vulnerability scanning, attribution report generation, and more.

Table of Contents

  1. Installation
  2. Getting Started
  3. User Manual
  4. Reporting Issues
  5. Contributing

Installation

Using the install script

FOSSA CLI provides an install script that downloads the latest release from GitHub Releases for your computer's architecture. You can see the source code and flags at install-latest.sh for Mac and Linux or install-latest.ps1 for Windows.

NOTE: You may need to add the downloaded executable to your $PATH. The installer script will output the installed path of the executable. You can also use -b to pick the installation directory when using install-latest.sh (see the install-latest.sh source code for details).

macOS or 64-bit Linux

curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash

macOS with brew

brew update # Fetch the newest version of Homebrew and all formulae
brew install --cask fossa

The FOSSA CLI version in the brew cask is updated to the latest version every 3 hours.

Windows with Powershell

Set-ExecutionPolicy Bypass -Scope Process -Force; iex  ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.ps1'))

Alternatively, install using Scoop:

scoop install fossa

Please refer to detailed walkthrough Installing FOSSA CLI, for installing FOSSA CLI 1.x and using GitHub Releases to install FOSSA CLI manually.

Getting Started

Integrating your project with FOSSA

TL;DR, Linux, Mac, *nix-like

# Download FOSSA.
curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash

# Set your API key. Get this from the FOSSA web application.
export FOSSA_API_KEY=XXXX

# Run an analysis in your project's directory.
cd $MY_PROJECT_DIR
fossa analyze

TL;DR, Windows

# Download FOSSA.
Set-ExecutionPolicy Bypass -Scope Process -Force; iex  ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.ps1'))

# Set your API key. Get this from the FOSSA web application.
$env:FOSSA_API_KEY=XXXX

# Run an analysis in your project's directory.
cd $MY_PROJECT_DIR
fossa analyze

Installing FOSSA CLI

Follow the installation instructions above to install the FOSSA CLI. Once installed, you should have a new binary named fossa available on your $PATH.

Generating an API key

To get started with integrating your project into FOSSA, you'll need to generate an API key. You'll get this API key from the FOSSA web application (app.fossa.com).

Once you have your API key:

export FOSSA_API_KEY=XXXX # Use your API key here.

Running an analysis

Now we can run an analysis. To run an analysis, all you need to do is navigate to your project's directory and run fossa analyze.

NOTE: While fossa will try its best to report available results for any kind of project, you'll get the best results by running in a directory with a working project build. A working build lets us integrate directly with your build tool to identify dependencies, instead of trying to infer dependencies from your source code.

$ cd $MY_PROJECT_DIR # Use your actual project location here.

$ fossa analyze
[ INFO] Using project name: `https://github.com/fossas/fossa-cli`
[ INFO] Using revision: `09ca72e398bb32747b27c0f43731678fa42c3c26`
[ INFO] Using branch: `No branch (detached HEAD)`
[ INFO] ============================================================

      View FOSSA Report:
      https://app.fossa.com/projects/custom+1%2fgithub.com%2ffossas%2ffossa-cli/refs/branch/master/09ca72e398bb32747b27c0f43731678fa42c3c26

  ============================================================

Viewing your results

Once an analysis has been uploaded, you can view your results in the FOSSA web application. You can see your analysis by using the link provided as output by fossa analyze, or by navigating to your project and revision in the FOSSA web application.

What next?

Now that your analysis is complete, there are a couple things you might want to do after an initial integration:

  • Double-check your results. Some analysis methods may produce partial or unexpected results depending on what information was available when you ran the analysis. If something seems wrong, our debugging guide can help you diagnose and debug your integration.

  • Scan for issues and generate a compliance report. Once your analysis is ready, we'll automatically queue an issue scan and report the results in the web application. Once an issue scan is complete, you can also generate a report from the web application.

  • Set up FOSSA in your CI. You can also use your issue scan results as inputs to CI scripts. For GitHub repositories, you can use FOSSA's native GitHub integration to report a status check on your PRs. For other CI integrations, you can also use fossa test to get programmatic issue status in CI.

User Manual

For most users, the FOSSA CLI will work out-of-the-box without any configuration. Just get an API key, run fossa analyze, and view your results in the FOSSA web application.

Users who need advanced customization or features should see the User Manual. Some common topics of interest include:

Reporting Issues

If you've found a bug or need support, the best way to get support is via the FOSSA support portal.

Make sure to include reproduction steps and any relevant project files (e.g. pom.xmls, package.jsons, etc.). Including the output from fossa analyze --debug in the email as well as any relevant fossa files (fossa-deps.json, .fossa.yml) will help expedite a solution.

We'll try to respond to issues opened in this repository on a best-effort basis, but we mostly provide support via the FOSSA support portal.

Contributing

If you're interested in contributing, check out our contributor documentation. PRs are welcome!

fossa-cli's People

Contributors

anuccio1 avatar cmboling avatar cnr avatar csasarak avatar elldritch avatar enricozb avatar gilfaizon avatar gtulipani avatar himynameisdave avatar jagonalez avatar jeffreyhuynh1 avatar jssblck avatar kenazk avatar meghfossa avatar pascal-hofmann avatar periodic avatar rolodato avatar ryanlink avatar saramaebee avatar skilly-lily avatar spatten avatar zlav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fossa-cli's Issues

Support module metadata

I want my modules to have more metadata than just name -- how about Url, Direct Deps and etc?

Separate REST operations into common utils

As we're going to have more commands operate as a REST client, there should be a common set of utils to make requests and handle common responses (i.e. invalid API keys, etc...)

Entry points should be more intuitive

Right now, we expect entry point paths to be folders to the working directory of the project. We optionally allow this to be a file only if the file's name follows the convention of the build system (e.g. if it's package.json for nodejs or build.sbt for sbt). The code that handles this is in //cmd/fossa/main.go under resolveModuleConfig.

This is not particularly intuitive behaviour because users may expect to be able to provide the path to their custom-named manifest (for example, a Maven build manifest may be named my-manifest.xml rather than pom.xml). There are two approaches to this:

  1. Require that entry points must be directories. This behaviour is consistent with the Go compiler's requirements.
  2. Call os.Stat on the entry point. If the entry point is a file (presumably because it's a manifest), call filepath.Dir on the entry point.

Approach (2) adds complexity and convenience, approach (1) reduces complexity and improves predictability.

Go analysis fails from within Docker containers

Steps to reproduce:

  1. Download alvin-huang/go-hello-world.
  2. Download fossa v0.3.1.
  3. Mount go-hello-world in its $GOPATH location within the golang:1.10-stretch container
  4. Run fossa analyze --modules go:. from within the go-hello-world directory in the container.

Interestingly, fossa works if you build it from source from within the Docker container. I suspect this has to do with our usage of KyleBanks/depth for import analysis -- something about a difference between the environment's Go and the Go used to compile fossa is breaking things.

Add supported tooling matrix and tests

fossa should have integration tests running across a variety of tooling versions so we can test, build and document compatibility with different versions of mvn, npm, and etc...

This should be represented as a matrix of supported versions in our docs.

Change fixture remotes to HTTPS URLs

Otherwise, users that don't have SSH set up with GitHub well get a permission denied error when they try to go get the fossa-cli project (because go get automatically runs git submodule update --init --recursive.

Improve autoconfiguration

In particular, we need to improve how we infer the project and revision. These don't currently happen correctly:

  1. Calls to git should run in the directory of the module, not the working directory of the process.
  2. There seems to be some bug where we don't correctly prefix git+ to certain projects. My suspicion is an issue with special characters. We should have a strongly typed format for locators that we pass around, rather than inferring locator sections using delimited string.

Add `vendor` dependency type

In many instances, I may want to simply define a module as a "vendorized" dependency.

  - name: rails
    path: Gemfile
    type: ruby
  # vendorized nodejs module required by rails-ujs
  - name: actioncable
    path: actioncable/package.json
    type: vendor
  - name: rails-ujs
    path: actionview/package.json
    type: nodejs

The behavior should be:

  1. If I have a vendorized dep at a certain path, other builders should ignore it (possibly in fossa init)
  2. Vendorized deps should avoid being built
  3. Vendorized deps should be treated as a dep of the top-level src unit (possibly returned in a VendorizedDeps json entry), and transformed into a locator

Output flag should intake a value

The -o flags behavior should perform as follows:

  1. If a param is specified i.e. fossa -o output.json, it should write to the output file.
  2. If a the flag is run alone with no param i.e. fossa -o it should write to stdout

Add non-interactive flags

When running in debug mode, interactive widgets like spinners make output really annoying to read. The two flags that would help are:

  • --no-spinner (perhaps --no-interactive or --no-ansi?): turn off spinners and other ANSI widgets
  • --no-color: turn off colour codes.

Process shell command output as a stream

Right now, we buffer the shell command's stdout and process it all at once after the command completes. Ideally, we would process the output line-by-line as it becomes available.

This is most important for the SBT and Maven plugins, which are incredibly slow. It's also theoretically useful for Ruby and Composer, although the need is less pressing here.

Advantages of stream processing:

  • Avoid keeping a stdout buffer
  • Show interactive progress as the shell command runs (at the very least in debug mode)

Improve testing

We've got a good framework for manual integration testing, but there's a lot of room for improvements here:

  • Run integration tests automatically in CI.
  • Set up golden files in integration tests and CI so that we know when output changes occur.
  • Refactor effecting code to take a service-provided implementation (in preparation for unit tests).
  • Add automatic unit tests (for pure logic such as parsing).

Add `fossa init`

Add a command that re-writes analyze.modules in .fossa.yml based off any discovered modules.

  • Ensure interface to easily serialize and de-serialize config from/to yml
  • Add fossa-cli comment header on config write
  • Rename builder.InferModule(target string) to builder.DiscoverModules(dir string)
  • Implement builder.DiscoverModule for node
  • Add behavior to default cmd if we are missing critical config
  • Add flag to default cmd to force updating config
  • Implement "fail-open" flag if a module has an error in default cmd
  • fully implement DiscoverModules across all currently-supported build systems

Add unit tests to builders

Builders are hard to test right now because they do a lot of IO. In particular:

  • Reading manifests from the filesystem
  • Reading environment variables for user-defined binaries
  • Reading shell output from build tool processes

To set up unit tests, we need to refactor all effecting functions to use a service provider instead, so we can mock out the service provide with pure implementations at test time.

This looks like a good use case for dependency injection, if we find something exceptionally light weight. I'd rather keep things simple, and at this point we could just create a service that's always passed to the builders (maybe as a public property in all of their structs, or in the Initialize method?).

Refactor common build utilities

There are a few common build utilities that should be refactored:

  • Checking which command to run (given a default, some fallbacks, and an environment variable)
  • Searching for project manifests
  • Running commands in a specified directory, and getting stdout and stderr as strings.

Ambiguous error message when provided builds is disabled

When pushing provided builds to FOSSA, if the enable provided builds checkbox is not checked, fossa-cli gives me:

CRITICAL Upload failed: bad server response ("\"This project is not configured to accept Provided Builds. Set `require_mediated_dependencies` to `true` in order to enable\"")

However, this is not exactly true. Once you check the checkbox for enable provided builds it will allow you to push without having to check the box for prefer mediated data. Should these two settings be turned on and off together?

Automatically run integration tests

We've got a lot of great testing fixtures right now, but none of them run automatically. We need to set up a script to automatically build and run FOSSA against these fixtures, and compare any output against golden files.

Improve error messages

Error messages are currently geared towards being clear for CLI developers, not end users. The general theme is that some very general failure modes (e.g. bad server response code) usually occur for very specific reasons (e.g. user forgot to upload this revision). Here are some improvements:

  • Better error message for a locator that isn't found (usually due to bad locator configuration or VCS inference)
  • Better error message for invalid API key is invalid during fossa test
  • Running fossa test on a non-existent revision only responds with 500
  • Distinguish between "user has not uploaded provided build" and "FOSSA has not yet applied the provided build" during fossa test

Add `fossa upload` command

This will be the start of a plugin architecture, where arbitrary commands can provide output to fossa upload and let the FOSSA CLI take care of authentication, constructing the API endpoint, etc.

This will allow end users to run their own analysis tools as long as they conform to the FOSSA source unit specification.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.