Skip to content

sharpstone/force_absolute_paths_buildpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published