neetob 0.3.2 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +4 -1
- data/data/github-labels.json +11 -1
- data/lib/neetob/cli/github/brakeman.rb +56 -0
- data/lib/neetob/cli/github/commands.rb +10 -0
- data/lib/neetob/cli/github/make_pr/base.rb +4 -0
- data/lib/neetob/cli/github/make_pr/compliance_fix.rb +1 -5
- data/lib/neetob/cli/github/protect_branch.rb +12 -1
- data/lib/neetob/version.rb +1 -1
- data/neetob.gemspec +2 -0
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0efeb267893c2c4b205174f5c8e98f995b96ecb9c897802a7a6ebb69b35c948b
|
4
|
+
data.tar.gz: b67600bfdfbb52cc703ca194db5d68e2353dc0d3533f038b2a2a3085a4ab37b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37aaf0fc506ab02bf04450e54de083cefe1b953620f8ec73ad08e0dbb35dc245420af2b98fdd1cc4acb3c4ee5b58ddf377dd5c7ae7f4af9a43bb812eb12edcfe
|
7
|
+
data.tar.gz: e09bebaa6f439bcbb217de61a9822df674bfaab52f1a22680b4eccb45a0bd2d759122c257a487bacb582c4a8ae5d815c7ed0359e53a2dbe6630c0d7ca84e3b83
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
### [0.4.1](https://www.github.com/bigbinary/neetob/compare/v0.4.0...v0.4.1) (2023-04-05)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* Updated README.md ([#250](https://www.github.com/bigbinary/neetob/issues/250)) ([ff4f1ed](https://www.github.com/bigbinary/neetob/commit/ff4f1ed67c361805856ed54df02565d7873a45ba))
|
9
|
+
|
10
|
+
## [0.4.0](https://www.github.com/bigbinary/neetob/compare/v0.3.2...v0.4.0) (2023-04-05)
|
11
|
+
|
12
|
+
|
13
|
+
### Features
|
14
|
+
|
15
|
+
* Added command to run brakeman on all neeto-repos ([#234](https://www.github.com/bigbinary/neetob/issues/234)) ([12123b4](https://www.github.com/bigbinary/neetob/commit/12123b48cc0d63ca0dd8a9e894a86a3a44a72d9e))
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* Fixes protect-branch command to ignore semaphore checks for repos that doesn't have it. ([#231](https://www.github.com/bigbinary/neetob/issues/231)) ([5da7e34](https://www.github.com/bigbinary/neetob/commit/5da7e34365f0f2460e88f35ced241c91200400dc))
|
21
|
+
* Updated the neetob.gemspec file to include the chronic gem dependancy ([#242](https://www.github.com/bigbinary/neetob/issues/242)) ([4f375ff](https://www.github.com/bigbinary/neetob/commit/4f375ff3cd6bb2b14c2d046d6c07420adadcf4ff))
|
22
|
+
|
3
23
|
### [0.3.2](https://www.github.com/bigbinary/neetob/compare/v0.3.1...v0.3.2) (2023-03-29)
|
4
24
|
|
5
25
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
neetob (0.
|
4
|
+
neetob (0.4.1)
|
5
|
+
brakeman (~> 5.0)
|
6
|
+
chronic
|
5
7
|
dotenv (~> 2.8.1)
|
6
8
|
launchy (~> 2.5.0)
|
7
9
|
octokit (~> 4.0)
|
@@ -88,6 +90,7 @@ GEM
|
|
88
90
|
public_suffix (>= 2.0.2, < 6.0)
|
89
91
|
ansi (1.5.0)
|
90
92
|
ast (2.4.2)
|
93
|
+
brakeman (5.4.1)
|
91
94
|
builder (3.2.4)
|
92
95
|
byebug (11.1.3)
|
93
96
|
childprocess (4.1.0)
|
data/data/github-labels.json
CHANGED
@@ -238,5 +238,15 @@
|
|
238
238
|
"name": "manual-qa-completed",
|
239
239
|
"description": "Manual QA team has finished verifying the changes.",
|
240
240
|
"color": "CCDDCD"
|
241
|
-
}
|
241
|
+
},
|
242
|
+
{
|
243
|
+
"name": "description-needed",
|
244
|
+
"description": "More description is needed for this issue either to work on it or to test the fix.",
|
245
|
+
"color": "E54D50"
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"name": "discussion",
|
249
|
+
"description": "Further discussion is required to work on this issue. Better we should move it to neetoPlanner's roadmap.",
|
250
|
+
"color": "A62F71"
|
251
|
+
},
|
242
252
|
]
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./make_pr/base"
|
4
|
+
|
5
|
+
module Neetob
|
6
|
+
class CLI
|
7
|
+
module Github
|
8
|
+
class Brakeman < MakePr::Base
|
9
|
+
DESCRIPTION = "Fix security vulnerabilities reported by brakeman"
|
10
|
+
attr_accessor :repos, :sandbox
|
11
|
+
|
12
|
+
def initialize(repos, sandbox = false)
|
13
|
+
super()
|
14
|
+
@repos = repos
|
15
|
+
@sandbox = sandbox
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox)
|
20
|
+
matching_repos.each do |repo|
|
21
|
+
begin
|
22
|
+
ui.info("\nWorking on repo #{repo}")
|
23
|
+
clone_repo_in_tmp_dir(repo)
|
24
|
+
bundle_install(repo)
|
25
|
+
report = run_brakeman(repo)
|
26
|
+
ui.success("Successfully executed brakeman for #{repo}")
|
27
|
+
warnings = report.split("\n\n== Warnings ==\n\n").last&.split("\n\n")
|
28
|
+
if !report.include?("No warnings found")
|
29
|
+
issue = client.create_issue(repo, DESCRIPTION, parse_description(warnings))
|
30
|
+
ui.success("Issue created at #{issue.html_url}")
|
31
|
+
end
|
32
|
+
rescue StandardError => e
|
33
|
+
ExceptionHandler.new(e).process
|
34
|
+
end
|
35
|
+
end
|
36
|
+
`rm -rf /tmp/neetob`
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def run_brakeman(repo)
|
42
|
+
`#{cd_to_repo_in_tmp_dir(repo)} && brakeman`
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_description(warnings)
|
46
|
+
warning_descriptions = warnings.map do |warning|
|
47
|
+
code_line = warning.scan(/Code: (.*)\n/).flatten.first
|
48
|
+
warning.gsub!(code_line, "`#{code_line}`") if !code_line.nil?
|
49
|
+
"```bash #{warning} \n```"
|
50
|
+
end
|
51
|
+
warning_descriptions.join("\n")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -8,6 +8,7 @@ require_relative "protect_branch"
|
|
8
8
|
require_relative "login"
|
9
9
|
require_relative "make_pr/commands"
|
10
10
|
require_relative "gems/commands"
|
11
|
+
require_relative "brakeman"
|
11
12
|
|
12
13
|
module Neetob
|
13
14
|
class CLI
|
@@ -52,6 +53,15 @@ module Neetob
|
|
52
53
|
ProtectBranch.new(
|
53
54
|
options[:branch], options[:repos], options[:path], options[:sandbox]).run
|
54
55
|
end
|
56
|
+
|
57
|
+
desc "brakeman", "Run brakeman on neeto repos & create issues in repos where needed"
|
58
|
+
option :repos, type: :array, aliases: "-r",
|
59
|
+
desc:
|
60
|
+
"Github repo names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\", also providing \"all\" as value matches all neeto repos.",
|
61
|
+
required: true
|
62
|
+
def brakeman
|
63
|
+
Brakeman.new(options[:repos], options[:sandbox]).run
|
64
|
+
end
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
@@ -23,7 +23,7 @@ module Neetob
|
|
23
23
|
matching_repos = should_fix_nanos ?
|
24
24
|
add_org_suffix(find_all_matching_gems) :
|
25
25
|
find_all_matching_apps_or_repos(repos, :github, sandbox)
|
26
|
-
@failed_repos = matching_repos
|
26
|
+
@failed_repos = matching_repos.clone
|
27
27
|
delete_and_create_temp_neetob_dir
|
28
28
|
matching_repos.each do |repo|
|
29
29
|
ui.info("\nWorking on #{repo}\n")
|
@@ -47,10 +47,6 @@ module Neetob
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
def bundle_install(repo)
|
51
|
-
`#{cd_to_repo_in_tmp_dir(repo)} && bundle install`
|
52
|
-
end
|
53
|
-
|
54
50
|
def fix_neeto_audit(repo)
|
55
51
|
`#{cd_to_repo_in_tmp_dir(repo)} && bundle exec neeto-audit -a`
|
56
52
|
end
|
@@ -6,7 +6,7 @@ module Neetob
|
|
6
6
|
class CLI
|
7
7
|
module Github
|
8
8
|
class ProtectBranch < Base
|
9
|
-
attr_accessor :branch_name, :required_rules_json_file_path, :repos, :sandbox
|
9
|
+
attr_accessor :branch_name, :required_rules_json_file_path, :repos, :repos_integrated_with_semaphore, :sandbox
|
10
10
|
|
11
11
|
def initialize(branch_name, repos, required_rules_json_file_path = "", sandbox = false)
|
12
12
|
super()
|
@@ -14,6 +14,7 @@ module Neetob
|
|
14
14
|
@required_rules_json_file_path = required_rules_json_file_path
|
15
15
|
@repos = repos
|
16
16
|
@sandbox = sandbox
|
17
|
+
@repos_integrated_with_semaphore = build_repos_integrated_with_semaphore_list.compact
|
17
18
|
end
|
18
19
|
|
19
20
|
def run
|
@@ -22,7 +23,9 @@ module Neetob
|
|
22
23
|
matching_repos.each do |repo|
|
23
24
|
ui.info("\n Working on \"#{repo}\" repo")
|
24
25
|
ui.info(" Updating \"#{branch_name}\" branch protection rules")
|
26
|
+
has_semaphore_integrated = repos_integrated_with_semaphore.include?(repo)
|
25
27
|
rules = read_json_file(required_rules_json_file_path || default_rules_file_path)
|
28
|
+
rules.dig("required_status_checks", "contexts")&.clear if !has_semaphore_integrated
|
26
29
|
rules_with_symbol_keys = rules.transform_keys(&:to_sym)
|
27
30
|
client.protect_branch(repo, branch_name, rules_with_symbol_keys)
|
28
31
|
ui.success("Branch protection rules updated successfully")
|
@@ -40,6 +43,14 @@ module Neetob
|
|
40
43
|
ui.info("Updating protection rules from the \"neetob/data/branch-protection-rules.json\" file")
|
41
44
|
end
|
42
45
|
end
|
46
|
+
|
47
|
+
def build_repos_integrated_with_semaphore_list
|
48
|
+
all_repos = NeetoCompliance::NeetoRepos.repos.values.flatten
|
49
|
+
all_repos.map! do |repo_config|
|
50
|
+
repo_config.is_a?(Hash) ? repo_config.to_a.map { |values| { values[0] => values[1] } } : repo_config
|
51
|
+
end
|
52
|
+
all_repos.flatten.map { |repo| (repo.is_a?(Hash) && repo.values[0].dig("semaphore")) ? "bigbinary/#{repo.keys[0]}" : nil }
|
53
|
+
end
|
43
54
|
end
|
44
55
|
end
|
45
56
|
end
|
data/lib/neetob/version.rb
CHANGED
data/neetob.gemspec
CHANGED
@@ -35,6 +35,8 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency "terminal-table", "~> 3.0.2" # for building cli table
|
36
36
|
spec.add_dependency "launchy", "~> 2.5.0" # for opening in browser
|
37
37
|
spec.add_dependency "dotenv", "~> 2.8.1" # for loading env variables
|
38
|
+
spec.add_dependency "chronic" # for natural language date and time parsing
|
39
|
+
spec.add_dependency "brakeman", "~> 5.0" # for running brakeman commands
|
38
40
|
|
39
41
|
# To add the files from submodules
|
40
42
|
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neetob
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Udai Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 2.8.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: chronic
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: brakeman
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.0'
|
83
111
|
description: This gem gives different commands for interacting with Github and Heroku
|
84
112
|
instances of existing neeto repos.
|
85
113
|
email:
|
@@ -119,6 +147,7 @@ files:
|
|
119
147
|
- lib/neetob/cli/fetchorupdate_repos/execute.rb
|
120
148
|
- lib/neetob/cli/github/auth.rb
|
121
149
|
- lib/neetob/cli/github/base.rb
|
150
|
+
- lib/neetob/cli/github/brakeman.rb
|
122
151
|
- lib/neetob/cli/github/commands.rb
|
123
152
|
- lib/neetob/cli/github/gems/commands.rb
|
124
153
|
- lib/neetob/cli/github/gems/release.rb
|