1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00
Commit graph

24 commits

Author SHA1 Message Date
Matt Brictson
9c92ad51ed
Security: randomize path of git wrapper script
Before, the `:git_wrapper_path` was a somewhat predictable value and
located in `/tmp` by default, which is world-writable. That meant that
there was a chance (albeit very small) that another process could guess
the path and overwrite it with something malicious.

Fix by randomly generating a path name so that the git wrapper script
location cannot be predicted.

This change should be transparent to capistrano users since the
`:git_wrapper_path` is only intended to be used internally. If you need
a predictable value for this path, set a custom value for
`:git_wrapper_path` in your `deploy.rb` file.
2021-01-05 07:57:02 -08:00
David Michael Nelson
f79a386aad Prevents last good release from being deleted on cleanup (#1922)
* Prevents last good release from being deleted on cleanup

Issue: 1907

If there are many failed deployments the relese folders will
still be left there and eventually if deploy:cleanup is
executed it will delete the release that is referenced by the
"current" symlink, potentially causing downtime.

That change will prevent the "current release" from ever being
removed during cleanup.

* Link PR on CHANGELOG

* Verify if current dir exists

Check if current release directory exists instead of relying on
exceptions being raised.
2017-10-12 12:40:57 -07:00
Darwin D Wu
a76b0766b0 deploy:cleanup should skip only the invalid releases and continue the rotation of releases (#1899)
* deploy:cleanup should skip only the invalid releases and continue the rotation
of releases

* Add cucumber tests for deploy:cleanup

* PR feedback

* rebase on master

* add ruby 2.4.1 to specs

* vagrant works with bundler 1.15.3

* remove unnecessary command
2017-07-22 16:15:44 -07:00
Berin Larson
ed0a3f08df Adds acceptance test for rollback feature. (#1891)
* #1736 Adds acceptance test for rollback feature.
* Made vagrant_cli_command function return values explicitly over setting instance variables.
2017-07-04 19:02:58 -07:00
Matt Brictson
55c684f8a0
Properly shell escape git:wrapper steps
The `upload!` method does escaping of its own internally, so we don't
need to do anything special there. Likewise environment variables are
already handled. The only place we need to explicitly `shellescape` is
when executing the `chmod` command.

Verify this all works as expected by changing the user in the Cucumber
features to be `(GitHub Web Flow) via ShipIt`. This user is now used
when exercising the `git:check` task.

Fixes #1842.
2017-02-09 21:45:06 -08:00
Maciek Dubinski
b3f7c46c19 Restricting the uploaded git wrapper file permissions to 700.
Additional step in the 'Creating the repo' scenario to test this adjustment.
2016-05-17 16:25:38 +02:00
William Johnston
9dc9462d04 Fix Style/SpaceAroundBlockParameters 2016-02-28 17:56:07 -06:00
William Johnston
b53e550fc0 Fix Style/StringLiterals 2016-02-28 17:56:07 -06:00
Chad Shaffer
d6f4499ee8 Address all rubocop lint warnings
* (File, Dir).exists? -> (File, Dir).exist?
* Prepend unused parameter names with an underscore
* Prefer “safe assignment in condition”
* Disambiguate splat operators with parens
* Remove unnecessary assignments (unused variables)
* No longer shadow Vagrant config variable name in Vagrantfile
* Removed some trailing whitespace

Fixes #1404
2015-08-14 14:21:34 -07:00
Lee Hambley
bb2b5f3232 Revert "Issue/1404" 2015-03-30 10:23:29 +02:00
Paul Schreiber
62246c997c fixes most of #1404
remaining:
lib/capistrano/configuration/question.rb:41:7: W: Do not suppress exceptions.
      rescue Errno::EIO
      ^^^^^^^^^^^^^^^^^
spec/support/Vagrantfile:8:47: W: Shadowing outer local variable - config.
    config.vm.define(role, primary: true) do |config|
                                              ^^^^^^
2015-03-29 22:28:21 -04:00
Nick Townsend
263295c423 Improve Cucumber tests
The test for SSH connection name switching was faulty
Improve the regexes used in the assertions
2015-02-14 11:32:45 -08:00
Sergey Ponomarev
859eec68c6 Fix cucumber spec for loading tasks from stage configs 2014-12-10 01:13:19 +03:00
Lee Hambley
f6af81c405 Fix rspec assertion be_false != be_falsey 2014-11-24 23:00:58 +01:00
Bruno Sutic
f26ee568e2 Update 'symlink linked files' cucumber scenario
When `deploy:symlink:linked_files` task is executed, only the
release path (containing the timestamp) is created.
After the task is done, it is hard to navigate over that release path
(again, because it's a timestamp) to perform the assertions.

To solve the issue, we're additionally creating a current path because
the assertion is much more easily done via `current_path`.
2014-11-17 13:47:24 +01:00
Bruno Sutic
c123fc1def Update 'checking linked files' cucumber scenarios
'Checking linked files' scenarios were passing, but the steps were not
defined at all.
This commit defines the required steps.
2014-11-17 13:47:24 +01:00
Bruno Sutic
a4e11a1435 Delete duplicate cucumber assertion that is unused 2014-11-17 13:47:24 +01:00
Bruno Sutic
a91d4eef0c Update assertions for 'git:check' test scenario
Capistrano 'git:check' task executes a `git ls-remote -h #{repo_url}`
command to check if remote repo is accessible. If successful, command
output is a list of references and their SHAs.

Task should be successful and we're pretty sure remote repo will have a
`master` reference, so that's what we're asserting.

We're NOT asserting:
 * repo references other than master - likely to change
 * reference SHAs - will definitely change
2014-11-17 13:47:24 +01:00
Rustam Zagirov
2c14957bf4 move to rspec 3 2014-08-12 22:52:37 +04:00
Travis Petticrew
2e13a1319c Cucumber tests will now run on the latest Vagrant
This removes the dependency on the `kuroko` gem and uses the Vagrant
command line application to control the virtual environment. The
`vagrant` command should be in your path, but if it isn't the path can
be set with the `VAGRANT_BIN` environment variable. This may even work
on older versions of Vagrant, but they are untested.

The `VagrantHelpers` module was added to mimic some of the API that was
provided by `kuroko`. The `RemoteCommandHelpers` module was modified to
accommodate those changes. Any non-zero exit status on a remote command
will raise a `VagrantHelpers::VagrantSSHCommandError` and should be
expected by any tests using the command helpers. All existing tests
work as expected.

In addition, a couple of minor changes were made. The TestApp utilizes
the Pathname library but does not require it. This was causing the suite
to fail for me so I added an explicit require. Also, the test for the
existence of a release directory would give a false positive on
subsequent runs if the `KEEP_RUNNING` option was used. I added an
`at_exit` that removes the test deployment directory to clean up the
box for the next run.

Documentation was also added to the README for how to run the test
suites.
2014-04-23 10:19:20 -05:00
Michael Nikitochkin
816b137930 🐼 Updated the loading default config tasks and stages config tasks.
To show all tasks decalred in default config and stages files was missed from the tasks list.
Added default value for :stage and load all default configs. Also added cucumber tests.
2014-01-18 23:18:55 +02:00
seenmyfate
7432c710b0 Add hook for deploy failure
If an error is raised during a deploy, the task `deploy:failed` will be
triggered.  Custom tasks can hook into this using `after`:

    after 'deploy:failed', :send_for_help do
      #
    end

I've also taken the opportunity to provide a marginally more useful
error message before triggering the task.

By default, this 'deploy:failed' will only be triggered when running
`cap <stage> deploy` - to trigger after individual tasks use `set
:deploying, true`

This closes #708 and replaces
https://github.com/capistrano/capistrano/pull/720
2013-11-01 12:24:36 +00:00
seenmyfate
d8b9b695bb Allow configuration location to be configurable
This change allows both the `deploy_config_path` and `stage_config_path`
to be moved from the default locations of `config/deploy.rb` and
`config/deploy` respectively.  These values __must__ be set in the
`Capfile` prior to `capistrano/setup` being called, for example:

    set :deploy_config_path, 'app/config/deploy.rb'
    set :stage_config_path, 'app/config/deploy'

    # Load DSL and Setup Up Stages
    require 'capistrano/setup'

Fixes #610
2013-10-14 12:44:38 +01:00
seenmyfate
e7399f4692 Integration tests with Vagrant and Cucumber
This commit removes the existing 'local' integration tests and replaces
them with Cucumber features running against VMs.  At this stage,
some of the assertions are pending due to the limited nature of the
response returned when executing commands through Vagrant, but the
framework is there as a starting point to build upon.

To run the suite:

    bundle exec cucumber

During development, avoid scraping the VM between runs:

    bundle exec cucumber KEEPING_RUNNING=1

Ultimately I would like to see the `TestApp` helpers along with the Vagrant
integration packaged and available for use when developing gems that work with
Cap. For now though, this closes #641
2013-09-27 11:45:55 +01:00