metasploit-yard 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +24 -0
- data/.rspec +2 -0
- data/.simplecov +42 -0
- data/.travis.yml +21 -0
- data/.yardopts +7 -0
- data/CONTRIBUTING.md +172 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +29 -0
- data/README.md +114 -0
- data/Rakefile +19 -0
- data/config/cucumber.yml +6 -0
- data/features/rake_task.feature +90 -0
- data/features/step_definitions/project.rb +25 -0
- data/features/step_definitions/rvm.rb +48 -0
- data/features/support/env.rb +6 -0
- data/lib/metasploit/yard/aruba/rvm_env/export.rb +87 -0
- data/lib/metasploit/yard/aruba/rvm_env/prepend.rb +47 -0
- data/lib/metasploit/yard/aruba/rvm_env/unset.rb +56 -0
- data/lib/metasploit/yard/aruba/rvm_env/variable.rb +44 -0
- data/lib/metasploit/yard/aruba/rvm_env.rb +103 -0
- data/lib/metasploit/yard/aruba.rb +6 -0
- data/lib/metasploit/yard/railtie.rb +12 -0
- data/lib/metasploit/yard/version.rb +43 -0
- data/lib/metasploit/yard.rb +18 -0
- data/lib/tasks/yard.rake +58 -0
- data/metasploit-yard.gemspec +36 -0
- data/spec/metasploit/yard/version_spec.rb +143 -0
- data/spec/metasploit/yard_spec.rb +15 -0
- data/spec/spec_helper.rb +77 -0
- metadata +222 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NTdkZGNmNDA2OTM2N2Y0OTE0OTg2YzA5ZTQwNTA4ZmVlMWUzOWFkNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGVlN2FkOTMzYjZmNTMzMTAwYjZkMmMxYjdjMDcwNjg4MzI0NTg0Yw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
M2Y4Y2Q1ZjRlODZmZGY2Njk0MDkwODk3ZWE4ZGJmYzc4NWQwYjBmYTI0Nzk2
|
10
|
+
ZWRjNGRmNDdlOWY2NGFjODRiN2Y2MTJlODFkOWRiMjExNzI4YWE3ZjAwYzc5
|
11
|
+
ZDU3NjYwMGJmMDY1ZGE4NWY3ODNmNzY1YjZmMmZlYjMyODdhMWE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWYxZTVhNWQyYjU2Y2YwZjIzZDQ0ZjY0OTQ1YmY4NzM5Mjc0Y2RjNWZiMTFh
|
14
|
+
NWJiMTI3Y2IyYTI0ZjAyYzJhOGUxYzIyY2RjYTZmM2M3YWQ3ZGU3MGU0ZGVh
|
15
|
+
ODhlNTU1ODEwNDJlMGI5YjUwYzUzMjk3MDk1YTEzZjYyNzRlM2M=
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Rubymine
|
2
|
+
/.idea
|
3
|
+
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
.bundle
|
7
|
+
.config
|
8
|
+
.yardoc
|
9
|
+
Gemfile.lock
|
10
|
+
InstalledFiles
|
11
|
+
_yardoc
|
12
|
+
coverage
|
13
|
+
doc/
|
14
|
+
lib/bundler/man
|
15
|
+
pkg
|
16
|
+
rdoc
|
17
|
+
spec/reports
|
18
|
+
test/tmp
|
19
|
+
test/version_tmp
|
20
|
+
tmp
|
21
|
+
|
22
|
+
# RVM
|
23
|
+
.ruby-version
|
24
|
+
.ruby-gemset
|
data/.rspec
ADDED
data/.simplecov
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# RM_INFO is set when using Rubymine. In Rubymine, starting SimpleCov is
|
2
|
+
# controlled by running with coverage, so don't explicitly start coverage (and
|
3
|
+
# therefore generate a report) when in Rubymine. This _will_ generate a report
|
4
|
+
# whenever `rake spec` is run.
|
5
|
+
unless ENV['RM_INFO']
|
6
|
+
SimpleCov.start
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
# ignore this file
|
11
|
+
add_filter '.simplecov'
|
12
|
+
|
13
|
+
# Rake tasks aren't tested with rspec
|
14
|
+
add_filter 'Rakefile'
|
15
|
+
add_filter 'lib/tasks'
|
16
|
+
|
17
|
+
#
|
18
|
+
# Changed Files in Git Group
|
19
|
+
# @see http://fredwu.me/post/35625566267/simplecov-test-coverage-for-changed-files-only
|
20
|
+
#
|
21
|
+
|
22
|
+
untracked = `git ls-files --exclude-standard --others`
|
23
|
+
unstaged = `git diff --name-only`
|
24
|
+
staged = `git diff --name-only --cached`
|
25
|
+
all = untracked + unstaged + staged
|
26
|
+
changed_filenames = all.split("\n")
|
27
|
+
|
28
|
+
add_group 'Changed' do |source_file|
|
29
|
+
changed_filenames.detect { |changed_filename|
|
30
|
+
source_file.filename.end_with?(changed_filename)
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
add_group 'Libraries', 'lib'
|
35
|
+
|
36
|
+
#
|
37
|
+
# Specs are reported on to ensure that all examples are being run and all
|
38
|
+
# lets, befores, afters, etc are being used.
|
39
|
+
#
|
40
|
+
|
41
|
+
add_group 'Specs', 'spec'
|
42
|
+
end
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
env:
|
2
|
+
global:
|
3
|
+
- secure: "IxVtzpee/XU/Qkw9g88uXX9GtQkzeUNVx05LYpfBuZWjQZWggrTp4k91HyquBNZkg30I5l7iHLbuhMB2c2SyNPN1OfkkhWZjeerJzRtaGDn7RXTAfdKUCtDceZPnl9Kv4Wbk6I2pVsXpROOP0VaPjLgod7aJqHfnw4AvP8yZbDg="
|
4
|
+
matrix:
|
5
|
+
- RAKE_TASK=cucumber
|
6
|
+
- RAKE_TASK=spec
|
7
|
+
language: ruby
|
8
|
+
matrix:
|
9
|
+
# documentation coverage is not influenced by ruby implementation, so only run once
|
10
|
+
include:
|
11
|
+
- rvm: 2.1
|
12
|
+
env: RAKE_TASK=yard
|
13
|
+
rvm:
|
14
|
+
- '1.9.3'
|
15
|
+
- '2.0'
|
16
|
+
- '2.1'
|
17
|
+
- 'ruby-head'
|
18
|
+
# jruby fails rake cucumber (see MSP-11240)
|
19
|
+
# - 'jruby-19mode'
|
20
|
+
- 'rbx-2.2'
|
21
|
+
script: "bundle exec rake $RAKE_TASK"
|
data/.yardopts
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
## Forking
|
4
|
+
|
5
|
+
[Fork this repository](https://github.com/rapid7/metasploit-yard/fork)
|
6
|
+
|
7
|
+
## Branching
|
8
|
+
|
9
|
+
Branch names follow the format `TYPE/ISSUE/SUMMARY`. You can create it with `git checkout -b TYPE/ISSUE/SUMMARY`.
|
10
|
+
|
11
|
+
### `TYPE`
|
12
|
+
|
13
|
+
`TYPE` can be `bug`, `chore`, or `feature`.
|
14
|
+
|
15
|
+
### `ISSUE`
|
16
|
+
|
17
|
+
`ISSUE` is either a [Github issue](https://github.com/rapid7/metasploit-yard/issues) or an issue from some other
|
18
|
+
issue tracking software.
|
19
|
+
|
20
|
+
### `SUMMARY`
|
21
|
+
|
22
|
+
`SUMMARY` is is short summary of the purpose of the branch composed of lower case words separated by '-' so that it is a valid `PRERELEASE` for the Gem version.
|
23
|
+
|
24
|
+
## Changes
|
25
|
+
|
26
|
+
### `PRERELEASE`
|
27
|
+
|
28
|
+
1. Update `PRERELEASE` to match the `SUMMARY` in the branch name. If you branched from `master`, and [version.rb](lib/metasploit/yard/version.rb) does not have `PRERELEASE` defined, then adding the following lines after `PATCH`:
|
29
|
+
```
|
30
|
+
# The prerelease version, scoped to the {PATCH} version number.
|
31
|
+
PRERELEASE = '<SUMMARY>'
|
32
|
+
```
|
33
|
+
2. `rake spec`
|
34
|
+
3. Verify the specs pass, which indicates that `PRERELEASE` was updated correctly.
|
35
|
+
4. Commit the change `git commit -a`
|
36
|
+
|
37
|
+
### Your changes
|
38
|
+
|
39
|
+
Make your changes or however many commits you like, commiting each with `git commit`.
|
40
|
+
|
41
|
+
### Pre-Pull Request Testing
|
42
|
+
|
43
|
+
1. Run specs one last time before opening the Pull Request: `rake spec`
|
44
|
+
2. Verify there was no failures.
|
45
|
+
|
46
|
+
### Push
|
47
|
+
|
48
|
+
Push your branch to your fork on gitub: `git push push TYPE/ISSUE/SUMMARY`
|
49
|
+
|
50
|
+
### Pull Request
|
51
|
+
|
52
|
+
* [Create new Pull Request](https://github.com/rapid7/metasploit-yard/compare/)
|
53
|
+
* Add a Verification Steps comment
|
54
|
+
|
55
|
+
```
|
56
|
+
# Verification Steps
|
57
|
+
|
58
|
+
- [ ] `bundle install`
|
59
|
+
|
60
|
+
## `rake cucumber`
|
61
|
+
- [ ] `rake cucumber`
|
62
|
+
- [ ] VERIFY no failures
|
63
|
+
|
64
|
+
## `rake spec`
|
65
|
+
- [ ] `rake spec`
|
66
|
+
- [ ] VERIFY no failures
|
67
|
+
```
|
68
|
+
You should also include at least one scenario to manually check the changes outside of specs.
|
69
|
+
|
70
|
+
* Add a Post-merge Steps comment
|
71
|
+
|
72
|
+
The 'Post-merge Steps' are a reminder to the reviewer of the Pull Request of how to update the [`PRERELEASE`](lib/metasploit/yard/version.rb) so that [version_spec.rb](spec/lib/metasploit/yard/version_spec.rb) passes on the target branch after the merge.
|
73
|
+
|
74
|
+
DESTINATION is the name of the destination branch into which the merge is being made. SOURCE_SUMMARY is the SUMMARY from TYPE/ISSUE/SUMMARY branch name for the SOURCE branch that is being made.
|
75
|
+
|
76
|
+
When merging to `master`:
|
77
|
+
|
78
|
+
```
|
79
|
+
# Post-merge Steps
|
80
|
+
|
81
|
+
Perform these steps prior to pushing to master or the build will be broke on master.
|
82
|
+
|
83
|
+
## Version
|
84
|
+
- [ ] Edit `lib/metasploit/yard/version.rb`
|
85
|
+
- [ ] Remove `PRERELEASE` and its comment as `PRERELEASE` is not defined on master.
|
86
|
+
|
87
|
+
## Gem build
|
88
|
+
- [ ] gem build *.gemspec
|
89
|
+
- [ ] VERIFY the gem has no '.pre' version suffix.
|
90
|
+
|
91
|
+
## RSpec
|
92
|
+
- [ ] `rake spec`
|
93
|
+
- [ ] VERIFY version examples pass without failures
|
94
|
+
|
95
|
+
## Commit & Push
|
96
|
+
- [ ] `git commit -a`
|
97
|
+
- [ ] `git push origin master`
|
98
|
+
```
|
99
|
+
|
100
|
+
When merging to DESTINATION other than `master`:
|
101
|
+
|
102
|
+
```
|
103
|
+
# Post-merge Steps
|
104
|
+
|
105
|
+
Perform these steps prior to pushing to DESTINATION or the build will be broke on DESTINATION.
|
106
|
+
|
107
|
+
## Version
|
108
|
+
- [ ] Edit `lib/metasploit/yard/version.rb`
|
109
|
+
- [ ] Change `PRERELEASE` from `SOURCE_SUMMARY` to `DESTINATION_SUMMARY` to match the branch (DESTINATION) summary (DESTINATION_SUMMARY)
|
110
|
+
|
111
|
+
## Gem build
|
112
|
+
- [ ] gem build *.gemspec
|
113
|
+
- [ ] VERIFY the prerelease suffix has change on the gem.
|
114
|
+
|
115
|
+
## RSpec
|
116
|
+
- [ ] `rake spec`
|
117
|
+
- [ ] VERIFY version examples pass without failures
|
118
|
+
|
119
|
+
## Commit & Push
|
120
|
+
- [ ] `git commit -a`
|
121
|
+
- [ ] `git push origin DESTINATION`
|
122
|
+
```
|
123
|
+
|
124
|
+
* Add a 'Release Steps' comment
|
125
|
+
|
126
|
+
The 'Release Steps' are a reminder to the reviewer of the Pull Request of how to release the gem.
|
127
|
+
|
128
|
+
```
|
129
|
+
# Release
|
130
|
+
|
131
|
+
Complete these steps on DESTINATION
|
132
|
+
|
133
|
+
## `VERSION`
|
134
|
+
|
135
|
+
### Incompatible API changes
|
136
|
+
|
137
|
+
If your changes are incompatible with the previous branch's API, such as removing APIs or removing parts of API
|
138
|
+
signatures:
|
139
|
+
|
140
|
+
- [ ] Increment [`MAJOR`](lib/metasploit/yard/version.rb)
|
141
|
+
- [ ] Reset [`MINOR`](lib/metasploit/yard/version.rb) to `0`
|
142
|
+
- [ ] Reset [`PATCH`](lib/metasploit/yard/version.rb) to `0`
|
143
|
+
- [ ] Commit
|
144
|
+
|
145
|
+
### Compatible API changes
|
146
|
+
|
147
|
+
If your changes are compatible with the previous branch's API, such as adding an API or adding options or optional
|
148
|
+
positional arguments to an API:
|
149
|
+
|
150
|
+
- [ ] Increment [`MINOR`](lib/metasploit/yard/version.rb)
|
151
|
+
- [ ] Reset [`PATCH`](lib/metasploit/yard/version.rb) to `0`.
|
152
|
+
- [ ] Commit
|
153
|
+
|
154
|
+
### Compatible bug fixes
|
155
|
+
|
156
|
+
If your changes are a bug fix that don't impact the APIs, then:
|
157
|
+
|
158
|
+
- [ ] Increment [`PATCH`](lib/metasploit/yard/version.rb)
|
159
|
+
- [ ] Commit
|
160
|
+
|
161
|
+
## MRI Ruby
|
162
|
+
- [ ] `rvm use ruby-2.1@metasploit-yard`
|
163
|
+
- [ ] `rm Gemfile.lock`
|
164
|
+
- [ ] `bundle install`
|
165
|
+
- [ ] `rake release`
|
166
|
+
```
|
167
|
+
|
168
|
+
### Downstream dependencies
|
169
|
+
|
170
|
+
When releasing new versions, the following projects may need to be updated:
|
171
|
+
|
172
|
+
(no current downstream dependents)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
BSD-3-clause License
|
2
|
+
|
3
|
+
Copyright (c) 2013-2014, Rapid7, Inc.
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without modification,
|
7
|
+
are permitted provided that the following conditions are met:
|
8
|
+
.
|
9
|
+
* Redistributions of source code must retain the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer.
|
11
|
+
.
|
12
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
.
|
16
|
+
* Neither the name of Rapid7, Inc. nor the names of its contributors
|
17
|
+
may be used to endorse or promote products derived from this software
|
18
|
+
without specific prior written permission.
|
19
|
+
.
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
21
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
22
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
24
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
25
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
26
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
27
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
28
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
29
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# Metasploit::Yard [![Build Status](https://travis-ci.org/rapid7/metasploit-yard.svg?branch=master)](https://travis-ci.org/rapid7/metasploit-yard)[![Code Climate](https://codeclimate.com/github/rapid7/metasploit-yard.png)](https://codeclimate.com/github/rapid7/metasploit-yard)[![Test Coverage](https://codeclimate.com/github/rapid7/metasploit-yard/badges/coverage.svg)](https://codeclimate.com/github/rapid7/metasploit-yard)[![Coverage Status](https://img.shields.io/coveralls/rapid7/metasploit-yard.svg)](https://coveralls.io/r/rapid7/metasploit-yard)[![Dependency Status](https://gemnasium.com/rapid7/metasploit-yard.svg)](https://gemnasium.com/rapid7/metasploit-yard)[![Gem Version](https://badge.fury.io/rb/metasploit-yard.svg)](http://badge.fury.io/rb/metasploit-yard)[![Inline docs](http://inch-ci.org/github/rapid7/metasploit-yard.svg?branch=master)](http://inch-ci.org/github/rapid7/metasploit-yard)[![PullReview stats](https://www.pullreview.com/github/rapid7/metasploit-yard/badges/master.svg)](https://www.pullreview.com/github/rapid7/metasploit-yard/reviews/master)
|
2
|
+
|
3
|
+
`metasploit-yard` holds the YARD rake task, in [`lib/tasks/yard.rake`](lib/tasks.yard.rake) used across all
|
4
|
+
`metasploit-*` projects. The rake task is defined here to prevent code duplication and task redefinitions in a gem's
|
5
|
+
dependencies leading to duplicate task actions, which led to yard docs being generated up to 6 times in some projects.
|
6
|
+
|
7
|
+
## Versioning
|
8
|
+
|
9
|
+
`Metasploit::Yard` is versioned using [semantic versioning 2.0](http://semver.org/spec/v2.0.0.html). Each branch
|
10
|
+
should set `Metasploit::Yard::Version::PRERELEASE` to the branch name, while master should have no `PRERELEASE`
|
11
|
+
and the `PRERELEASE` section of `Metasploit::Yard::VERSION` does not exist.
|
12
|
+
|
13
|
+
## Documentation
|
14
|
+
|
15
|
+
`Metasploit::Yard` is documented using YARD. In fact, it uses the same rake task as it exports for other gems to use.
|
16
|
+
|
17
|
+
### Generate
|
18
|
+
|
19
|
+
rake yard
|
20
|
+
|
21
|
+
### Reading
|
22
|
+
|
23
|
+
open doc/frames.html
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
### Project with only a Gemfile
|
28
|
+
|
29
|
+
Add this line to your application's `Gemfile`:
|
30
|
+
|
31
|
+
gem 'metasploit-yard', group: :development
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
|
35
|
+
$ bundle
|
36
|
+
|
37
|
+
### Project with a gemspec
|
38
|
+
|
39
|
+
Add this line to your gem's gemspec:
|
40
|
+
|
41
|
+
spec.add_development_dependency 'metasploit-yard'
|
42
|
+
|
43
|
+
And then execute:
|
44
|
+
|
45
|
+
$ bundle
|
46
|
+
|
47
|
+
### Otherwise
|
48
|
+
|
49
|
+
Or install it yourself as:
|
50
|
+
|
51
|
+
$ gem install metasploit-yard
|
52
|
+
|
53
|
+
## Setup
|
54
|
+
|
55
|
+
### In a Rails::Application
|
56
|
+
|
57
|
+
`metasploit-yard` has a `Rails::Railtie`, [`Metasploit::Yard::Railtie`](lib/metasploit/yard/railtie) that will
|
58
|
+
automatically be loaded if `Rails` is defined when `metasploit/yard` is required. `Metasploit::Yard::Railtie` will
|
59
|
+
automatically load [`yard.rake`](lib/tasks/yard.rake) for your Rails project.
|
60
|
+
|
61
|
+
### In a Rails::Engine or non-Rails gem
|
62
|
+
|
63
|
+
Add the following to your `Rakefile` to load `yard.rake` from `metasploit-yard`
|
64
|
+
|
65
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
66
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-yard').first
|
67
|
+
|
68
|
+
Dir[File.join(gem_specification.gem_dir, 'lib', 'tasks', '**', '*.rake')].each do |rake|
|
69
|
+
load rake
|
70
|
+
end
|
71
|
+
|
72
|
+
## Usage
|
73
|
+
|
74
|
+
$ rake yard
|
75
|
+
|
76
|
+
### CI Integration
|
77
|
+
|
78
|
+
`rake yard` will automatically call `rake yard:stats`. `rake yard:stats` will exit with status `0` only if there are
|
79
|
+
no undocumented objects. If there are undocumented objects, then `rake yard:stats` will exist with status `1`. If
|
80
|
+
you want to lower the threshold of undocumented objects that are allowed from `100.0` percentage, set the value in
|
81
|
+
`config/yard-stats-threshold` as a float.
|
82
|
+
|
83
|
+
By adding `rake yard:stats` to the tasks run by your CI server, you can have your build fail if documentation slips
|
84
|
+
below the threshold.
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
89
|
+
|
90
|
+
## Testing
|
91
|
+
|
92
|
+
`Metasploit::Yard` is tested using [RSpec](https://github.com/rspec/rspec)
|
93
|
+
|
94
|
+
### Dependencies
|
95
|
+
|
96
|
+
Remove your `Gemfile.lock` so you test with the latest compatible dependencies as will be done on
|
97
|
+
[travis-ci](https://travis-ci.org/rapid7/metasploit-yard)
|
98
|
+
|
99
|
+
rm Gemfile.lock
|
100
|
+
bundle install
|
101
|
+
|
102
|
+
### Database Setup
|
103
|
+
|
104
|
+
To run the specs, access to the database is required, so setup the `database.yml`, create the database, and run the
|
105
|
+
migrations:
|
106
|
+
|
107
|
+
cp spec/dummy/config/database.yml.example spec/dummy/config/database.yml
|
108
|
+
# fill in passwords
|
109
|
+
edit spec/dummy/config/database.yml
|
110
|
+
rake db:create db:migrate
|
111
|
+
|
112
|
+
### Running
|
113
|
+
|
114
|
+
rake spec
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'cucumber'
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
7
|
+
t.cucumber_opts = "features --format pretty"
|
8
|
+
end
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
|
12
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
13
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-yard').first
|
14
|
+
|
15
|
+
Dir[File.join(gem_specification.gem_dir, 'lib', 'tasks', '**', '*.rake')].each do |rake|
|
16
|
+
load rake
|
17
|
+
end
|
18
|
+
|
19
|
+
task :default => :spec
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
Feature: yard.rake
|
2
|
+
|
3
|
+
In order to generate documentation for metasploit projects, but not end up with multiple actions for the `yard` rake tasks
|
4
|
+
As a developer calling `rake yard`
|
5
|
+
I want `yard.rake` loaded from `metasploit-yard`
|
6
|
+
|
7
|
+
Scenario: Without Rails
|
8
|
+
Given I create a clean gemset "without_rails_use_metasploit_yard"
|
9
|
+
And I use gemset "without_rails_use_metasploit_yard"
|
10
|
+
And I successfully run `bundle gem without_rails_use_metasploit_yard`
|
11
|
+
And I cd to "without_rails_use_metasploit_yard"
|
12
|
+
And I overwrite "without_rails_use_metasploit_yard.gemspec" with:
|
13
|
+
"""
|
14
|
+
# coding: utf-8
|
15
|
+
lib = File.expand_path('../lib', __FILE__)
|
16
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
17
|
+
require 'without_rails_use_metasploit_yard/version'
|
18
|
+
|
19
|
+
Gem::Specification.new do |spec|
|
20
|
+
spec.name = 'without_rails_use_metasploit_yard'
|
21
|
+
spec.version = WithoutRailsUseMetasploitYard::VERSION
|
22
|
+
spec.authors = ['Luke Imhoff']
|
23
|
+
spec.email = ['luke_imhoff@rapid7.com']
|
24
|
+
spec.summary = 'Uses metasploit-yard without Rails'
|
25
|
+
spec.license = 'BSD-3-Clause'
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0")
|
28
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
29
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
30
|
+
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
spec.add_development_dependency 'bundler'
|
33
|
+
spec.add_development_dependency 'rake'
|
34
|
+
spec.add_development_dependency 'metasploit-yard'
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
And I append to "Rakefile" with:
|
38
|
+
"""
|
39
|
+
# Use find_all_by_name instead of find_by_name as find_all_by_name will return pre-release versions
|
40
|
+
gem_specification = Gem::Specification.find_all_by_name('metasploit-yard').first
|
41
|
+
|
42
|
+
Dir[File.join(gem_specification.gem_dir, 'lib', 'tasks', '**', '*.rake')].each do |rake|
|
43
|
+
load rake
|
44
|
+
end
|
45
|
+
"""
|
46
|
+
And I install the project gem locally
|
47
|
+
And I successfully run `bundle install`
|
48
|
+
When I run `rake yard`
|
49
|
+
Then the output should contain:
|
50
|
+
"""
|
51
|
+
Undocumented Objects:
|
52
|
+
WithoutRailsUseMetasploitYard (lib/without_rails_use_metasploit_yard.rb:3)
|
53
|
+
WithoutRailsUseMetasploitYard::VERSION (lib/without_rails_use_metasploit_yard/version.rb:2)
|
54
|
+
"""
|
55
|
+
And the stderr from "rake yard" should contain:
|
56
|
+
"""
|
57
|
+
Documentation percentage (0.00%) below threshold (100.00%)
|
58
|
+
"""
|
59
|
+
# Don't do this in a different scenario because it takes minutes to setup a new gem project
|
60
|
+
Given a file named "config/yard-stats-threshold" with:
|
61
|
+
"""
|
62
|
+
0.0
|
63
|
+
"""
|
64
|
+
When I successfully run `rake yard`
|
65
|
+
Then the output from "rake yard" should not contain "below threshold"
|
66
|
+
|
67
|
+
@travis-ci-wip
|
68
|
+
Scenario: With a Rails Application
|
69
|
+
Given I create a clean gemset "rails_application_use_metasploit_yard"
|
70
|
+
And I use gemset "rails_application_use_metasploit_yard"
|
71
|
+
And I successfully run `gem install rails`
|
72
|
+
And I successfully run `rails new rails_application_use_metasploit_yard --skip-action-view --skip-active-record --skip-javascript --skip-spring --skip-sprockets --skip-test-unit`
|
73
|
+
And I cd to "rails_application_use_metasploit_yard"
|
74
|
+
And I append to "Gemfile" with:
|
75
|
+
"""
|
76
|
+
gem 'metasploit-yard', group: :development
|
77
|
+
"""
|
78
|
+
And I install the project gem locally
|
79
|
+
And I successfully run `bundle install`
|
80
|
+
And a file named "config/yard-stats-threshold" with:
|
81
|
+
"""
|
82
|
+
0.0
|
83
|
+
"""
|
84
|
+
When I successfully run `rake yard`
|
85
|
+
Then the output should contain:
|
86
|
+
"""
|
87
|
+
Undocumented Objects:
|
88
|
+
ApplicationController (app/controllers/application_controller.rb:1)
|
89
|
+
ApplicationHelper (app/helpers/application_helper.rb:1)
|
90
|
+
"""
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Given(/^I install the project gem locally$/) do
|
2
|
+
process_name = "gem build metasploit-yard.gemspec"
|
3
|
+
root = Pathname.new(__FILE__).parent.parent.parent
|
4
|
+
current_pathname = Pathname.new(current_dir).expand_path
|
5
|
+
root_relative_to_current = root.relative_path_from(current_pathname)
|
6
|
+
current_relative_to_root = current_pathname.relative_path_from(root)
|
7
|
+
|
8
|
+
cd(root_relative_to_current)
|
9
|
+
run_simple(process_name)
|
10
|
+
cd(current_relative_to_root)
|
11
|
+
|
12
|
+
gem_build_output = get_process(process_name).output
|
13
|
+
match = gem_build_output.match(/^ File: (?<gem_file>.*)$/)
|
14
|
+
|
15
|
+
unless match
|
16
|
+
fail "Cannot parse gem build output for built gem name:\n#{gem_build_output}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# need to include root as this is back in tmp/aruba
|
20
|
+
gem_pathname = root.join(match[:gem_file])
|
21
|
+
|
22
|
+
run_simple("gem install #{gem_pathname}")
|
23
|
+
|
24
|
+
gem_pathname.delete
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'metasploit/yard/aruba/rvm_env'
|
2
|
+
|
3
|
+
Before do
|
4
|
+
@gemsets_to_delete = []
|
5
|
+
end
|
6
|
+
|
7
|
+
Given /^I create a clean gemset "(.*?)"$/ do |gemset|
|
8
|
+
run_simple("rvm gemset create #{gemset}")
|
9
|
+
@gemsets_to_delete << gemset
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^I use gemset "(.*?)"$/ do |gemset|
|
13
|
+
current_rvm_env_process_name = 'rvm env'
|
14
|
+
run_simple(current_rvm_env_process_name)
|
15
|
+
current_rvm_env = get_process(current_rvm_env_process_name).stdout
|
16
|
+
current_parsed = Metasploit::Yard::Aruba::RvmEnv.parse(current_rvm_env)
|
17
|
+
|
18
|
+
new_rvm_env_process_name = "rvm @#{gemset} do rvm env"
|
19
|
+
run_simple(new_rvm_env_process_name)
|
20
|
+
new_rvm_env = get_process(new_rvm_env_process_name).stdout
|
21
|
+
new_parsed = Metasploit::Yard::Aruba::RvmEnv.parse(new_rvm_env)
|
22
|
+
|
23
|
+
Metasploit::Yard::Aruba::RvmEnv.change(
|
24
|
+
from: current_parsed,
|
25
|
+
to: new_parsed,
|
26
|
+
world: self
|
27
|
+
)
|
28
|
+
|
29
|
+
#
|
30
|
+
# Remove this gem's bin from path so the gemset is required to declare the gem as a dependency to get access to the
|
31
|
+
# bins
|
32
|
+
#
|
33
|
+
|
34
|
+
directories = ENV['PATH'].split(File::PATH_SEPARATOR)
|
35
|
+
directories.shift
|
36
|
+
path = directories.join(File::PATH_SEPARATOR)
|
37
|
+
|
38
|
+
set_env('PATH', path)
|
39
|
+
|
40
|
+
unset_bundler_env_vars
|
41
|
+
end
|
42
|
+
|
43
|
+
After('~@no-clobber') do
|
44
|
+
@gemsets_to_delete.each do |gemset|
|
45
|
+
# --force to prevent confirmation prompt
|
46
|
+
run_simple("rvm gemset delete --force #{gemset}")
|
47
|
+
end
|
48
|
+
end
|