Git Product home page Git Product logo

force_absolute_paths_buildpack's Introduction

Force absolute paths buildpack

This buildpack checks that not relative paths have snuck into the PATH or any path like env vars (checks for all that end in PATH like GEM_PATH). The intention of this buildpack is that you could use it in a test suite for buildpacks.

This repo has a very simple script in lib/check_script.rb that when executed loops through each PATH-like env var and raises an error if one of them has a relative path. The script is executed at build time to catch any bad paths in export scripts. It also adds (or modifies) a release phase incantation to run at release time so it will check paths in a runtime like environment.

For example:

$ git push heroku master
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 185 bytes | 185.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> I check that all paths are absolute app detected
remote: -----> Checking for absolute values in PATHs
remote:        Everything looks good to me
remote: -----> Updating release script in procfile
remote: -----> Discovering process types
remote:        Procfile declares types -> release
remote:
remote: -----> Compressing...
remote:        Done: 667B
remote: -----> Launching...
remote:  !     Release command declared: this new release will not be available until the command succeeds.
remote:        Released v15
remote:        https://cryptic-gorge-80699.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
remote: Running release command...
remote:
remote: -----> Checking for absolute values in PATHs
remote: bin/check_paths:9:in `block in <main>': All paths must be absolute, ENV["GEM_PATH"] contains "blerg" with relative_path "blerg" (RuntimeError)
remote:   from bin/check_paths:6:in `each'
remote:   from bin/check_paths:6:in `<main>'
remote: Waiting for release.... failed.
To https://git.heroku.com/cryptic-gorge-80699.git
   6a83c41..5478677  master -> master

Checks

  • Check all paths are absolute
  • Check the build directory doesn't leak into a path at runtime (if build and runtime dirs are different)

Ignoring a path

This buildpack is greedy in checking all env vars that end in _PATH. If there's a env var that ends in _PATH that should be relative, you can ignore it by setting the FORCE_ABSOLUTE_PATHS_BUILDPACK_IGNORE_PATHS config value on the app. For example:

heroku config:set FORCE_ABSOLUTE_PATHS_BUILDPACK_IGNORE_PATHS=BUNDLE_PATH

This will tell this buildpack to ignore the BUNDLE_PATH env var. You can specify multiple values using a comma:

heroku config:set FORCE_ABSOLUTE_PATHS_BUILDPACK_IGNORE_PATHS=BUNDLE_PATH,IGNORE_THIS_PATH_TOO

force_absolute_paths_buildpack's People

Contributors

schneems avatar

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.