assemblyline-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d387b68c36f4806401ded2de6235b618db3497b5
4
+ data.tar.gz: 72deaf8e2902cb8d60410c3edb7810f9d10ad1a3
5
+ SHA512:
6
+ metadata.gz: f1a907d165b5705ae8b76cf5d5de9992531d46bce976310ca635794373e667c7a89f4bf85a23dbc0d50e6dc88aabf3a34e87acc2119e5d0e63547f6b4bea1623
7
+ data.tar.gz: bbd7fbe16d9527d9456da67bcedd86861007f9a63d1f06dd8f49da51c4d4b122372f98c2f9777fa3cbb88b3f956cfa61837210de300194bff41cd6a66f20504d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at ed@reevoo.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in assemblyline-ruby.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ed Robinson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Assemblyline
2
+ ## Ruby
3
+
4
+ This gem provides helpers to be used inside of Assemblyline ruby docker containers.
5
+
6
+ ## Usage
7
+
8
+ `a10e-install` - Installs the dependencies specfied in `Gemfile` and `Gemfile.lock`. Build time dependencies on system packages are infered, using a database.
9
+
10
+ ## License
11
+
12
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
13
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "reevoocop/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ ReevooCop::RakeTask.new(:reevoocop)
7
+
8
+ task default: [:spec, :reevoocop]
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "assemblyline/ruby/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "assemblyline-ruby"
8
+ spec.version = Assemblyline::Ruby::VERSION
9
+ spec.authors = ["Ed Robinson"]
10
+ spec.email = ["ed@reevoo.com"]
11
+
12
+ spec.summary = "This gem provides helpers to be used inside of Assemblyline ruby docker containers."
13
+ spec.description = "This gem provides helpers to be used inside of Assemblyline ruby docker containers."
14
+ spec.homepage = "http://www.a10e.org"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ spec.add_development_dependency "simplecov", "~> 0.11"
26
+ spec.add_development_dependency "reevoocop"
27
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "assemblyline/ruby"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh -xe
2
+
3
+ bundle install
data/exe/a10e_install ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "assemblyline/ruby/installer"
4
+
5
+ Assemblyline::Ruby::Installer.new.install do
6
+ fail unless system "bundle install -j4 -r3"
7
+ end
@@ -0,0 +1,7 @@
1
+ require "assemblyline/ruby/version"
2
+
3
+ module Assemblyline
4
+ module Ruby
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ require "assemblyline/ruby/provider"
2
+ require "assemblyline/ruby/system_packages"
3
+
4
+ module Assemblyline
5
+ module Ruby
6
+ class Installer
7
+ def initialize(provider = nil, system_packages = nil)
8
+ @provider = provider || Provider.provider
9
+ @system_packages = system_packages || SystemPackages.new
10
+ @base_packages = @provider.current_packages
11
+ end
12
+
13
+ def install
14
+ provider.install(system_packages.all) if system_packages.any?
15
+ yield
16
+ provider.remove(removable_packages) if system_packages.any?
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :provider, :base_packages, :system_packages
22
+
23
+ def removable_packages
24
+ provider.current_packages -
25
+ provider.required_packages -
26
+ system_packages.runtime -
27
+ base_packages
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ module Assemblyline
2
+ module Ruby
3
+ class Platform
4
+ def initialize(path = "/etc/os-release")
5
+ release = Hash[
6
+ File.read(path)
7
+ .tr("\"", "")
8
+ .split("\n").map { |row| row.split("=") }
9
+ ]
10
+ @id = release["ID"]
11
+ @like = release["ID_LIKE"]
12
+ @version = release["VERSION_ID"]
13
+ @pretty = release["PRETTY_NAME"]
14
+ end
15
+
16
+ attr_reader :id, :version, :like
17
+
18
+ def to_s
19
+ @pretty
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require "assemblyline/ruby/platform"
2
+
3
+ module Assemblyline
4
+ module Ruby
5
+ module Provider
6
+ extend self
7
+
8
+ def provider
9
+ platform = Platform.new
10
+ load_provider(platform.id)
11
+ rescue NameError, LoadError => e
12
+ begin
13
+ return load_provider(platform.like) if platform.like
14
+ fail e
15
+ rescue NameError, LoadError
16
+ raise "Platform: #{platform.id} not supported"
17
+ end
18
+ end
19
+
20
+ def load_provider(name)
21
+ require "assemblyline/ruby/provider/#{name}"
22
+ const_get(name.capitalize).new
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ module Assemblyline
2
+ module Ruby
3
+ module Provider
4
+ class Alpine
5
+ def current_packages
6
+ `apk info -s`.split("\n")
7
+ end
8
+
9
+ def install(packages)
10
+ fail unless system "apk add --no-cache #{packages.join(" ")}"
11
+ end
12
+
13
+ def remove(packages)
14
+ fail unless system "apk del #{packages.join(" ")}"
15
+ end
16
+
17
+ def required_packages
18
+ `scanelf --needed --nobanner --recursive /usr/local/bundle`.split("\n")
19
+ .map { |row| row.split[1].split(",") }
20
+ .flatten
21
+ .map { |file| `apk info --installed so:#{file}`.chomp }
22
+ .uniq.sort
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ module Assemblyline
2
+ module Ruby
3
+ module Provider
4
+ class Debian
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,60 @@
1
+ require "json"
2
+
3
+ module Assemblyline
4
+ module Ruby
5
+ class SystemPackages
6
+ def initialize(data = nil)
7
+ @data = data
8
+ end
9
+
10
+ def any?
11
+ all.any?
12
+ end
13
+
14
+ def all
15
+ build + runtime
16
+ end
17
+
18
+ def build
19
+ buildeps = dependencies("build")
20
+ buildeps += ["git"] if needs_git?
21
+ buildeps
22
+ end
23
+
24
+ def runtime
25
+ dependencies("runtime")
26
+ end
27
+
28
+ private
29
+
30
+ def needs_git?
31
+ lockfile.sources.any? { |source| source.is_a? Bundler::Source::Git }
32
+ end
33
+
34
+ def dependencies(context)
35
+ deps.map { |dep| dep[context] }.flatten.uniq.compact.sort
36
+ end
37
+
38
+ def deps
39
+ packages.map do |pkg|
40
+ data.select do |dep|
41
+ pkg == dep["name"]
42
+ end
43
+ end.flatten
44
+ end
45
+
46
+ def packages
47
+ lockfile.specs.map(&:name)
48
+ end
49
+
50
+ def lockfile
51
+ @_lockfile ||= Bundler::LockfileParser.new(File.read("Gemfile.lock"))
52
+ end
53
+
54
+
55
+ def data
56
+ @data ||= JSON.parse(File.read("/etc/assemblyline/dependencies.json"))
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,5 @@
1
+ module Assemblyline
2
+ module Ruby
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: assemblyline-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ed Robinson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.11'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: reevoocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: This gem provides helpers to be used inside of Assemblyline ruby docker
84
+ containers.
85
+ email:
86
+ - ed@reevoo.com
87
+ executables:
88
+ - a10e_install
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rspec"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - assemblyline-ruby.gemspec
100
+ - bin/console
101
+ - bin/setup
102
+ - exe/a10e_install
103
+ - lib/assemblyline/ruby.rb
104
+ - lib/assemblyline/ruby/installer.rb
105
+ - lib/assemblyline/ruby/platform.rb
106
+ - lib/assemblyline/ruby/provider.rb
107
+ - lib/assemblyline/ruby/provider/alpine.rb
108
+ - lib/assemblyline/ruby/provider/debian.rb
109
+ - lib/assemblyline/ruby/system_packages.rb
110
+ - lib/assemblyline/ruby/version.rb
111
+ homepage: http://www.a10e.org
112
+ licenses:
113
+ - MIT
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.4.5.1
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: This gem provides helpers to be used inside of Assemblyline ruby docker containers.
135
+ test_files: []