Skip to content

Commit

Permalink
Release v2.0.0 as a gem 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
Melvin Lammerts committed Nov 24, 2016
1 parent 971a31d commit 2f4af24
Show file tree
Hide file tree
Showing 25 changed files with 85 additions and 41 deletions.
1 change: 0 additions & 1 deletion .github-cookie

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.swp
!output/.gitkeep
output/*
*.gem
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ source 'https://rubygems.org'

gem 'pry'

gem 'require_all'
gem 'tty'
gem 'http'
gem 'nokogiri'
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ vcsmap is a plugin-based tool to scan public version control systems (currently
![vcsmap screenshot](https://cloud.githubusercontent.com/assets/1312973/17968763/ddda7682-6ace-11e6-80af-557a6997276c.png)

## Installation
Download the source code and run the following command. You need a recent version of Ruby with [bundler](http://bundler.io) and you might need build tools like `gcc` to build the dependencies.
``` ruby
$ bundle
Install the package wity RubyGems.
```
$ gem install vcsmap
```

## Usage
vcsmap already includes a couple of plugins. Each plugin looks for files that match a certain search query, and extracts the right data from those files. To view all plugins run:
```
$ ruby vcsmap.rb list
$ vcsmap list
```

To use a plugin, look up the name of the plugin (`[plugin_name]`) and run the following command. Data is saved in CSV format to the `output` directory.

**Due to a recent change you need to add a valid Github `user_session` cookie to `.github-cookie`.**
**To authenticate with Github you need to set a `GITHUB_COOKIE` environment variable with a valid Github `user_session` cookie value.**
```
$ ruby vcsmap.rb run {plugin_name} {pages} {--no-ascii}
$ vcsmap run {plugin_name} {pages} {--no-ascii}
```
- You need to specify the amount of pages you want to search. Each (GitHub) page has 10 possible results.
- Use the `--no-ascii` flag (last) to disable rendering the results as an ASCII table in the command line.
Expand Down
9 changes: 9 additions & 0 deletions bin/vcsmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')

require 'vcsmap'

cli = Vcsmap::CLI.new(ARGV)
cli.run
30 changes: 30 additions & 0 deletions lib/vcsmap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'http'
require 'yaml'
require 'nokogiri'

# TODO: include only if needed
require_relative 'vcsmap/cli'
require_relative 'vcsmap/csv_writer'
require_relative 'vcsmap/progress_bar'

require_relative 'vcsmap/helpers'
require_relative 'vcsmap/plugin'
require_relative 'vcsmap/plugin_list'
require_relative 'vcsmap/provider'

# TODO: work on require_all
require_relative 'vcsmap/plugins/base_plugin'
require_relative 'vcsmap/plugins/aws_access_token'
require_relative 'vcsmap/plugins/facebook_client_secrets'
require_relative 'vcsmap/plugins/filezilla_xml'
require_relative 'vcsmap/plugins/github_sublimesettings'
require_relative 'vcsmap/plugins/google_oauth'
require_relative 'vcsmap/plugins/instagram_tokens'
require_relative 'vcsmap/plugins/solr_dataconfig'
require_relative 'vcsmap/plugins/wordpress_config'

require_relative 'vcsmap/providers/github'

module Vcsmap
VERSION = '2.0.0'.freeze
end
13 changes: 8 additions & 5 deletions lib/cli.rb → lib/vcsmap/cli.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'tty'

module Vcsmap
class CLI
def initialize(arguments)
Expand All @@ -23,7 +25,7 @@ def run
private

def usage
"See #{Helpers::project_directory}/README.md or http://vcsmap.org for instructions."
"See http://vcsmap.org or open #{Helpers.project_directory}/README.md for instructions."
end

def list_plugins
Expand All @@ -34,8 +36,7 @@ def list_plugins

def run_plugin(no_ascii)
begin
plugin = PluginList.find(@plugin)
plugin = Object.const_get(plugin[:class_name]).new
plugin = PluginList.get_object(@plugin)
rescue KeyError
abort "Cannot find plugin with name '#{@plugin}'."
rescue NameError
Expand Down Expand Up @@ -66,8 +67,10 @@ def run_plugin(no_ascii)
data << credentials unless credentials[1].nil? || credentials[1].empty?
end

abort "Some files were loaded (#{results.count}), but none of them contained matching credentials. " \
'You could try a higher page number.' if data.empty?
if data.empty?
abort "Some files were loaded (#{results.count}), but none of them contained matching credentials. " \
'You could try a higher page number.'
end

bar.clear

Expand Down
4 changes: 3 additions & 1 deletion lib/csv_writer.rb → lib/vcsmap/csv_writer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'csv'

module Vcsmap
class CsvWriter
def initialize(plugin_name, plugin_header, data)
Expand All @@ -7,7 +9,7 @@ def initialize(plugin_name, plugin_header, data)
end

def write!
puts "Writing CSV to #{Helpers::project_directory}/#{@file_path} ..."
puts "Writing CSV to #{Helpers.project_directory}/#{@file_path} ..."
CSV.open(@file_path, 'wb', force_quotes: true) do |csv|
csv << @header
@data.each do |line|
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers.rb → lib/vcsmap/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Vcsmap
module Helpers
def self.project_directory
"#{File.dirname(File.dirname(__FILE__))}"
File.dirname(File.dirname(__FILE__)).to_s
end
end
end
File renamed without changes.
5 changes: 5 additions & 0 deletions lib/plugin_list.rb → lib/vcsmap/plugin_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def self.find(name)
PLUGINS.fetch(name.to_sym)
end

def self.get_object(name)
plugin = find(name)
Object.const_get(plugin[:class_name]).new
end

def self.render_list
all.each do |plugin|
puts Pastel.new.green "[#{plugin[0]}] #{plugin[1][:title]}"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions lib/progress_bar.rb → lib/vcsmap/progress_bar.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'tty'

module Vcsmap
class ProgressBar
def initialize(count)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/providers/github.rb → lib/vcsmap/providers/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def search(plugin, total_pages)
private

def get_cookie
cookie = File.read('.github-cookie').strip
cookie = ENV['GITHUB_COOKIE']
http = HTTP.cookies(user_session: cookie).get('https://github.com/login')
abort "[Error] No valid session cookie in #{Helpers::project_directory}/.github-cookie." unless http.status == 302
abort "[Error] No valid session cookie in ENV['GITHUB_COOKIE']." unless http.status == 302
cookie
end

Expand Down
18 changes: 18 additions & 0 deletions vcsmap.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require_relative 'lib/vcsmap'

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |s|
s.name = 'vcsmap'
s.version = Vcsmap::VERSION
s.licenses = ['MIT']
s.summary = 'Scans public repositories for sensitive information.'
s.description = 'A plugin-based tool to scan public version control systems for sensitive information.'
s.authors = ['Melvin Lammerts']
s.email = 'hi@melvin.sh'
s.files = Dir['lib/**/*.rb']
s.require_paths = ['lib']
s.executables = 'vcsmap'
s.homepage = 'http://vcsmap.org'
end
24 changes: 0 additions & 24 deletions vcsmap.rb
Original file line number Diff line number Diff line change
@@ -1,24 +0,0 @@
require 'tty'
require 'csv'
require 'http'
require 'yaml'
require 'nokogiri'
require 'require_all'

require_relative 'lib/cli'
require_relative 'lib/csv_writer'
require_relative 'lib/helpers'
require_relative 'lib/plugin'
require_relative 'lib/plugin_list'
require_relative 'lib/provider'
require_relative 'lib/progress_bar'

require_all 'lib/plugins'
require_all 'lib/providers'

module Vcsmap
VERSION = '1.0.3'.freeze

cli = Vcsmap::CLI.new(ARGV)
cli.run
end

0 comments on commit 2f4af24

Please sign in to comment.