neetob 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a5009ec9b17cb67db7709598632c5001f487460c4a393ff4415c657f8f2a26
4
- data.tar.gz: 7ef5bae6ffe881a4b3507865b35c56a68beb35cc0af5114cd348c163678fcc1d
3
+ metadata.gz: dfc6be750f749257d3d3f6a10f00a348dc746c34d69bdb1c9ccb76d44c9d260a
4
+ data.tar.gz: f217db9a99316cec947b70fd74f27b0f5c6285fe127b94fbf627bd6c559b399d
5
5
  SHA512:
6
- metadata.gz: 89aec8ad58378aef387e4bf6a2ac5b8bbc40cb15432a4c884b1ba05e752f660c0a8785b3021bdc98e85c193bfa8b505f36b5ba68ae428af08a36a2634e2112fb
7
- data.tar.gz: e4831981bfc7e6136489583f91f592aa2ff1931b9d248cfd3d2683a3128931fe9b1e5b58a6f94906d3d2a7c6e60923f125534b89cf0f17b00ceb3dd6e3a54e10
6
+ metadata.gz: 1edde424e4ff572f7f56ab45580c92bb5f574c411272f89e35f884e41d6aabdd8fa92d029783d8f7bb63551e29897020e58bef6bb1b427ae030d8f0782daf31c
7
+ data.tar.gz: 6aa6507b68340737f27a8f12910d12d5be7cf60de84796d169afd229fc712623440a0e9828bf42b45df9df8855ef0235062b050862f4050077b213a86c7d3c39
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0](https://www.github.com/bigbinary/neetob/compare/v0.3.2...v0.4.0) (2023-04-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * 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))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * 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))
14
+ * 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))
15
+
3
16
  ### [0.3.2](https://www.github.com/bigbinary/neetob/compare/v0.3.1...v0.3.2) (2023-03-29)
4
17
 
5
18
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetob (0.3.2)
4
+ neetob (0.4.0)
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)
@@ -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
@@ -19,6 +19,10 @@ module Neetob
19
19
 
20
20
  private
21
21
 
22
+ def bundle_install(repo)
23
+ `#{cd_to_repo_in_tmp_dir(repo)} && bundle install`
24
+ end
25
+
22
26
  def delete_and_create_temp_neetob_dir
23
27
  `rm -rf /tmp/neetob`
24
28
  `mkdir /tmp/neetob`
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neetob
4
- VERSION = "0.3.2"
4
+ VERSION = "0.4.0"
5
5
  end
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.3.2
4
+ version: 0.4.0
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-03-29 00:00:00.000000000 Z
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