neetob 0.5.59 → 0.5.62

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1e5c88e37056dc8f8e0c06286b82f6e24187dcc40deca062b81d3dd4d7ff4b5
4
- data.tar.gz: '01778584c7dee0fc8acb96d54438259f3408ea52dc34c12bbdcbaf0de53becf8'
3
+ metadata.gz: 522e7577ff2d936f74c82ccdd8470856da5bb902dfff67bc3645f1835eb32207
4
+ data.tar.gz: '0493281b373ed0a42c7be132afa77114f639295627c4029c1b1bc365a85a8b8d'
5
5
  SHA512:
6
- metadata.gz: fc91a29ca99035b6ae00a0e2a2fa0e1eabfeba58107790c9c672c048341c85cd08becb6d872f2e22fbf0c82f038373adb5190b94099a878329029ec54b1daa19
7
- data.tar.gz: 86bfa714a68b70f8df5ce5ddd068d63d844d77a0e3acf7d7dbf805f51c57cf6418e509b1f717bac150e6a72816e76830ccabb4f4523be8907fbd26a5b04b68ba
6
+ metadata.gz: 41dd6814485d8158d0a76742e489cc062bd672671a3157456ae9a9d0483b5013af87c9d72c4ae58e90ed2b3f4317662127e3bc7080ee7b4011834c2a77e6ac78
7
+ data.tar.gz: 37986d40c3aa2e3873e32f066cd049eacf27414df067c7b6033c532a0f9fda406726c8de68fed263b2662aab9db30ee25b057f50302aeac523993852d9443874
data/.env CHANGED
@@ -3,3 +3,11 @@ CLOUDFLARE_API_KEY='Bearer SPJSRAtx5kIIFzeBNb9X2G0PBZWF-pDhRr1gr77A'
3
3
  CRONITOR_ONE_API_KEY='00e1d2ad9d104967af53d42a52b76a1f'
4
4
  CRONITOR_THREE_API_KEY='989733e0eb87407b83ecef6e31768f28'
5
5
 
6
+
7
+ # WORKSPACE__APPNAME_API_KEY = ""
8
+
9
+ SAMPLEWORKSPACE__NEETOCHAT_API_KEY="API_KEY"
10
+ SAMPLEWORKSPACE__NEETOCAL_API_KEY="API_KEY"
11
+
12
+ SAMPLEHELP__NEETOCHAT_API_KEY="API_KEY"
13
+ SAMPLEHELP__NEETOCAL_API_KEY="API_KEY"
data/Gemfile CHANGED
@@ -34,6 +34,7 @@ gem "pry"
34
34
 
35
35
  gem "actionview"
36
36
  gem "activesupport"
37
+ gem "httparty"
37
38
 
38
39
  source "https://O6Ts9-SVDaUZpHMRs2CpJp22RwbETDE@gems.neeto.com" do
39
40
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neetob (0.5.59)
4
+ neetob (0.5.62)
5
5
  actionview
6
6
  activesupport
7
7
  brakeman (~> 5.0)
@@ -481,6 +481,7 @@ DEPENDENCIES
481
481
  dotenv (~> 2.8.1)
482
482
  faraday-retry
483
483
  fury
484
+ httparty
484
485
  minitest (~> 5.0)
485
486
  minitest-reporters
486
487
  mocha
data/README.md CHANGED
@@ -41,7 +41,10 @@ The `neetob` gem gives a different set of commands for interacting with Github r
41
41
  1. [Audit](#audit-1)
42
42
  11. [Working with local Repos](#working-with-local-repos)
43
43
  1. [ls](#ls)
44
- 12. [Testing](docs/testing.md)
44
+ 12. [Working with workspace permissions](#working-with-workspace-permissions)
45
+ 1. [Add user to all apps of a specific help workspace](#add-user-to-all-apps-of-a-specific-help-workspace)
46
+ 2. [Add user to all neeto help workspaces for a specific app](#add-user-to-all-neeto-help-workspaces-for-a-specific-app)
47
+ 13. [Testing](docs/testing.md)
45
48
 
46
49
  ## Usage
47
50
 
@@ -683,3 +686,21 @@ neetob local ls --dir public --apps "neeto-*-web"
683
686
  # List all the files in a nested directory
684
687
  neetob local ls --dir app/controllers --apps "neeto-*-web"
685
688
  ```
689
+
690
+ ## Working with workspace permissions
691
+
692
+ ### Add user to all apps of a specific help workspace
693
+
694
+ The `add_member_to_all_apps` command adds a user to all apps of a specific help workspace.
695
+
696
+ ```
697
+ neetob workspace_permission add_member_to_all_apps --workspace=neetocoursehelp --email=oliver@example.com --role=Admin
698
+ ```
699
+
700
+ ### Add user to all neeto help workspaces for a specific app
701
+
702
+ The `add_member_to_all_workspaces` command adds a user to all neeto help workspaces for a specific app
703
+
704
+ ```
705
+ neetob workspace_permission add_member_to_all_workspaces --app=neetocal --email=oliver@example.com --role="Admin"
706
+ ```
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./make_pr/base"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module Github
8
+ class FastererAudit < MakePr::Base
9
+ DESCRIPTION = "Fix optimization issues reported by fasterer"
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
+ report = nil
21
+ matching_repos.each do |repo|
22
+ begin
23
+ ui.info("\nWorking on repo #{repo}", print_to_audit_log: false)
24
+ clone_repo_in_tmp_dir(repo)
25
+ bundle_install!(repo)
26
+ report = run_fasterer(repo)
27
+ ui.success("Successfully executed fasterer for #{repo}", print_to_audit_log: false)
28
+ rescue StandardError => e
29
+ ExceptionHandler.new(e).process
30
+ end
31
+ end
32
+ `rm -rf /tmp/neetob` unless Thread.current[:audit_mode]
33
+ if Thread.current[:audit_mode]
34
+ report
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def run_fasterer(repo)
41
+ `#{cd_to_repo(repo)} && fasterer`
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -18,73 +18,12 @@ module Neetob
18
18
  meet.talkflowai.com
19
19
  ]
20
20
 
21
- DOMAINS_POINTING_TO_HEROKU = %w[
22
- forms.rvrsmartworks.com
23
- forms.cibereduca.org
24
- support.quirkyconsultant.com
25
- meet.perfey.de
26
- meet.aylett.co.uk
27
- meet.fastbound.com
28
- meet.canddi.com
29
- calendar.jimryan.ie
30
- meeting.caliham.com
31
- meet.stripedarts.com
32
- meet.tune.day
33
- meet.shiftx.com
34
- meeting.imarsrl.com
35
- calender.rvrsmartworks.com
36
- demo.variantspark.com
37
- ]
38
-
39
- DOMAINS_WITH_INVALID_CNAME_TARGET = %w[
40
- forms.thenumber.ninja
41
- racer.dingan.org
42
- forms.monadsys.com.au
43
- acumenn.money
44
- techzonce.com
45
- neerajsingh0202.com
46
- engage.quirkyconsultant.com
47
- ibymarketingdigital.com.br
48
- testdomain.cecieee.org
49
- help.neetopopups.com
50
- help.coombined.com
51
- help.neetosign.com
52
- unni-playground.dingan.org
53
- help.peerlist.io
54
- help.neetobugtrap.com
55
- help.neetosocial.com
56
- unni.dingan.org
57
- help.neetostore.com
58
- meet.quirkyconsultant.com
59
- interviews.activepresence.co
60
- book.navapi.com
61
- www.chessconfidence.com
62
- cal.arbaaz.io
63
- mapletalenthub.com
64
- massagebunnik.nl
65
- xplorify.bg
66
- hiredeasy.com
67
- meet.jijinkh.com
68
- waqualityroofing.com
69
- agenda.jylcontadoras.com.uy
70
- yvonnecano.com
71
- influenceintoincome.com
72
- design-narrative.com
73
- agenda.arma.com.mx
74
- bitzen.cl
75
- sanibeltreehouse.com
76
- creativechamps.in
77
- meet.sreeragmsadanandan.com
78
- SHINEBLUEAGENCY.COM
79
- amazyfvideos.com
80
- meet.alpexsolar.com
81
- calendar.alladvance.co.uk
82
- thegreenspace.in
83
- meet.kodair.us
84
- ]
21
+ NEETO_DEPLOY_DNS_TARGET = "dns.neetodeployapp.com"
22
+ HEROKU_DNS_TARGET = "herokudns.com"
85
23
 
86
24
  def initialize
87
25
  super()
26
+ @resolver = Resolv::DNS.new
88
27
  end
89
28
 
90
29
  def run
@@ -103,15 +42,9 @@ module Neetob
103
42
  else
104
43
  certificates_to_be_flagged = certificates_status.select { |certificate|
105
44
  certificate["expires_before_30_days"] &&
106
- !(certificate["domains"] || []).map {
45
+ (certificate["domains"] || []).map {
107
46
  |domain| domain["hostname"]
108
- }.any? { |domain|
109
- (
110
- DOMAINS_AUTO_RENEWED +
111
- DOMAINS_POINTING_TO_HEROKU +
112
- DOMAINS_WITH_INVALID_CNAME_TARGET
113
- ).include?(domain)
114
- }
47
+ }.any? { |domain| should_flag_domain?(domain) }
115
48
  }
116
49
  audit_passed = certificates_to_be_flagged.empty? ? "Yes" : "No"
117
50
  certificates_expiring_in_less_than_30_days = "Yes" if audit_passed == "No"
@@ -141,6 +74,48 @@ module Neetob
141
74
  end
142
75
  ui.print_table(apps_data)
143
76
  end
77
+
78
+ private
79
+
80
+ def should_flag_domain?(hostname)
81
+ valid_dns_configuration?(hostname) &&
82
+ !points_to_heroku?(hostname) &&
83
+ !DOMAINS_AUTO_RENEWED.include?(hostname)
84
+ end
85
+
86
+ def points_to_heroku?(hostname)
87
+ Timeout.timeout(10) do
88
+ cname_records = @resolver.getresources(hostname, Resolv::DNS::Resource::IN::CNAME)
89
+ cname_records.any? { |record| record.name.to_s.include?(HEROKU_DNS_TARGET) }
90
+ end
91
+ rescue Resolv::ResolvError, Timeout::Error => e
92
+ ui.error("Heroku DNS resolution failed for #{hostname}: #{e.message}")
93
+ false
94
+ end
95
+
96
+ def valid_dns_configuration?(hostname)
97
+ Timeout.timeout(10) do
98
+ cname_records = @resolver.getresources(hostname, Resolv::DNS::Resource::IN::CNAME)
99
+ return true if cname_records.any? { |record| record.name.to_s.include?(NEETO_DEPLOY_DNS_TARGET) }
100
+
101
+ if root_level_domain?(hostname)
102
+ a_records = @resolver.getresources(hostname, Resolv::DNS::Resource::IN::A)
103
+ target_a_records = @resolver.getresources(NEETO_DEPLOY_DNS_TARGET, Resolv::DNS::Resource::IN::A)
104
+ return true if a_records.any? do |record|
105
+ target_a_records.any? { |target| target.address.to_s == record.address.to_s }
106
+ end
107
+ end
108
+
109
+ false
110
+ end
111
+ rescue Resolv::ResolvError, Timeout::Error => e
112
+ ui.error("Neetodeploy DNS resolution failed for #{hostname}: #{e.message}")
113
+ false
114
+ end
115
+
116
+ def root_level_domain?(hostname)
117
+ hostname.split(".").length == 2
118
+ end
144
119
  end
145
120
  end
146
121
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../github/fasterer_audit"
4
+
5
+ module Neetob
6
+ class CLI
7
+ module MonthlyAudit
8
+ module Security
9
+ module Code
10
+ class Fasterer < CLI::Base
11
+ def initialize
12
+ super()
13
+ end
14
+
15
+ def run
16
+ ui.success("### 1.1.6. Checking whether running `bundle exec fasterer` give any suggestions")
17
+ repo_data = [["Repository", "Optimizations needed", "Comments", "Audit Passed"]]
18
+ ui.info "\n"
19
+ NeetoCompliance::NeetoRepos.products.keys.each do |repo|
20
+ ui.info("Checking Fasterer run results for #{repo}", print_to_audit_log: false)
21
+ fasterer_exec_result = Neetob::CLI::Github::FastererAudit.new([repo]).run
22
+ optimizations_needed = "No"
23
+ audit_passed = "No"
24
+ comments = nil
25
+ if fasterer_exec_result.include?("0 offenses detected")
26
+ audit_passed = "Yes"
27
+ comments = fasterer_exec_result
28
+ else
29
+ optimizations_needed = "Yes"
30
+ comments = fasterer_exec_result.gsub("\n", "<br>")
31
+ end
32
+ repo_data << [repo, optimizations_needed, comments, audit_passed]
33
+ end
34
+ ui.print_table(repo_data)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -5,6 +5,7 @@ require_relative "yarn_audit"
5
5
  require_relative "brakeman"
6
6
  require_relative "active_record_doctor"
7
7
  require_relative "checks_for_unused_assets"
8
+ require_relative "fasterer"
8
9
 
9
10
  module Neetob
10
11
  class CLI
@@ -26,6 +27,8 @@ module Neetob
26
27
  ActiveRecordDoctor.new.run
27
28
  ui.info "\n"
28
29
  ChecksForUnusedAssets.new.run
30
+ ui.info "\n"
31
+ Fasterer.new.run
29
32
  end
30
33
  end
31
34
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+ require_relative "./permission_helpers"
5
+ require "httparty"
6
+
7
+ module Neetob
8
+ class CLI
9
+ module WorkspacePermissions
10
+ class AddMemberToAllApps < Base
11
+ include PermissionHelpers
12
+
13
+ def initialize(workspace:, email:, role:)
14
+ super()
15
+ @workspace = workspace.downcase
16
+ @email = email
17
+ @role = role
18
+ end
19
+
20
+ def run
21
+ api_keys = parse_api_keys(group_by: :workspace)
22
+ unless api_keys[@workspace]
23
+ ui.error("No API keys found for Workspace: #{@workspace}")
24
+ return
25
+ end
26
+
27
+ ui.info("Adding #{@email} to all apps of #{@workspace} with role #{@role}")
28
+ api_keys[@workspace].each do |app, api_key|
29
+ url = build_url(@workspace, app)
30
+ post_member_to(
31
+ url:,
32
+ api_key:,
33
+ email: @email,
34
+ role: @role,
35
+ workspace: @workspace,
36
+ app:
37
+ )
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../base"
4
+ require_relative "./permission_helpers"
5
+ require "httparty"
6
+
7
+ module Neetob
8
+ class CLI
9
+ module WorkspacePermissions
10
+ class AddMemberToAllWorkspaces < Base
11
+ include PermissionHelpers
12
+
13
+ def initialize(app:, email:, role:)
14
+ super()
15
+ @app = app.downcase
16
+ @email = email
17
+ @role = role
18
+ end
19
+
20
+ def run
21
+ api_keys = parse_api_keys(group_by: :app)
22
+ unless api_keys[@app]
23
+ ui.error("No API keys found for app: #{@app}")
24
+ return
25
+ end
26
+
27
+ ui.info("Adding #{@email} to all workspaces of #{@app} with role #{@role}")
28
+ api_keys[@app].each do |workspace, api_key|
29
+ url = build_url(workspace, @app)
30
+ post_member_to(
31
+ url:,
32
+ api_key:,
33
+ email: @email,
34
+ role: @role,
35
+ workspace:,
36
+ app: @app
37
+ )
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require_relative "add_member_to_all_workspaces"
5
+ require_relative "add_member_to_all_apps"
6
+ module Neetob
7
+ class CLI
8
+ module WorkspacePermissions
9
+ class Commands < Thor
10
+ desc "add_member_to_all_workspaces", "Adds a user to all neeto help workspaces for a specific app."
11
+ option :app, type: :string, required: true, aliases: "-a", desc: "App name. Example: \"neetochat\"."
12
+ option :email, type: :string, required: true, aliases: "-e", desc: "Email of the user to be added to all workspaces."
13
+ option :role, type: :string, required: false, aliases: "-r", default: "Standard", desc: "Role of the user to be added to all workspaces. Default is Standard."
14
+ def add_member_to_all_workspaces
15
+ AddMemberToAllWorkspaces.new(
16
+ app: options[:app],
17
+ email: options[:email],
18
+ role: options[:role]
19
+ ).run
20
+ end
21
+
22
+ desc "add_member_to_all_apps", "Adds a user to all apps of a specific help workspace."
23
+ option :workspace, type: :string, required: true, aliases: "-w", desc: "Workspace name. Example: \"neetocoursehelp\"."
24
+ option :email, type: :string, required: true, aliases: "-e", desc: "Email of the user to be added to all workspaces."
25
+ option :role, type: :string, required: false, aliases: "-r", default: "Standard", desc: "Role of the user to be added to all apps. Default is Standard."
26
+ def add_member_to_all_apps
27
+ AddMemberToAllApps.new(
28
+ workspace: options[:workspace],
29
+ email: options[:email],
30
+ role: options[:role]
31
+ ).run
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lib/neetob/cli/workspace_permissions/team_member_adder.rb
4
+ module Neetob
5
+ class CLI
6
+ module WorkspacePermissions
7
+ module PermissionHelpers
8
+ def build_url(workspace, app)
9
+ "https://#{workspace}.#{app}.com/api/external/v1/team_members"
10
+ end
11
+
12
+ def parse_api_keys(group_by:)
13
+ ENV.each_with_object({}) do |(key, value), acc|
14
+ next unless key.end_with?("_API_KEY") && key.include?("__")
15
+
16
+ workspace_part, app_part = key.split("__", 2)
17
+ next unless app_part && workspace_part
18
+
19
+ workspace = workspace_part.downcase
20
+ app = app_part.gsub("_API_KEY", "").downcase
21
+
22
+ case group_by
23
+ when :workspace
24
+ acc[workspace] ||= {}
25
+ acc[workspace][app] = value
26
+ when :app
27
+ acc[app] ||= {}
28
+ acc[app][workspace] = value
29
+ end
30
+ end
31
+ end
32
+
33
+ def post_member_to(url:, api_key:, email:, role:, workspace:, app:)
34
+ body = {
35
+ organization_role: role,
36
+ emails: [email]
37
+ }
38
+
39
+ headers = {
40
+ "X-Api-Key" => api_key,
41
+ "Content-Type" => "application/json"
42
+ }
43
+
44
+ response = HTTParty.post(url, body: body.to_json, headers:)
45
+
46
+ if response.code == 200
47
+ ui.success("Added #{email} to #{workspace}.#{app} with role #{role}")
48
+ else
49
+ ui.error("Failed to add #{email} to #{workspace}.#{app}. Status: #{response.code}")
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
data/lib/neetob/cli.rb CHANGED
@@ -15,6 +15,7 @@ module Neetob
15
15
  require_relative "cli/neeto_deploy/commands"
16
16
  require_relative "cli/redirections/commands"
17
17
  require_relative "cli/monthly_audit/commands"
18
+ require_relative "cli/workspace_permissions/commands"
18
19
 
19
20
  class_option :sandbox,
20
21
  {
@@ -62,5 +63,8 @@ module Neetob
62
63
 
63
64
  desc "monthly_audit", "Monthly audit of all the neeto apps/domains/functionalities/ops"
64
65
  subcommand "monthly_audit", MonthlyAudit::Commands
66
+
67
+ desc "workspace_permissions", "Manage workspace permissions"
68
+ subcommand "workspace_permissions", WorkspacePermissions::Commands
65
69
  end
66
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neetob
4
- VERSION = "0.5.59"
4
+ VERSION = "0.5.62"
5
5
  end
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.5.59
4
+ version: 0.5.62
5
5
  platform: ruby
6
6
  authors:
7
7
  - Udai Gupta
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-05 00:00:00.000000000 Z
11
+ date: 2025-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -239,6 +239,7 @@ files:
239
239
  - lib/neetob/cli/github/brakeman.rb
240
240
  - lib/neetob/cli/github/bundle_audit.rb
241
241
  - lib/neetob/cli/github/commands.rb
242
+ - lib/neetob/cli/github/fasterer_audit.rb
242
243
  - lib/neetob/cli/github/gems/commands.rb
243
244
  - lib/neetob/cli/github/gems/release.rb
244
245
  - lib/neetob/cli/github/issues/commands.rb
@@ -315,6 +316,7 @@ files:
315
316
  - lib/neetob/cli/monthly_audit/security/code/brakeman.rb
316
317
  - lib/neetob/cli/monthly_audit/security/code/bundle_audit.rb
317
318
  - lib/neetob/cli/monthly_audit/security/code/checks_for_unused_assets.rb
319
+ - lib/neetob/cli/monthly_audit/security/code/fasterer.rb
318
320
  - lib/neetob/cli/monthly_audit/security/code/main.rb
319
321
  - lib/neetob/cli/monthly_audit/security/code/yarn_audit.rb
320
322
  - lib/neetob/cli/monthly_audit/security/github/dependabot_prs_merged.rb
@@ -342,6 +344,10 @@ files:
342
344
  - lib/neetob/cli/users/audit.rb
343
345
  - lib/neetob/cli/users/commands.rb
344
346
  - lib/neetob/cli/users/commits.rb
347
+ - lib/neetob/cli/workspace_permissions/add_member_to_all_apps.rb
348
+ - lib/neetob/cli/workspace_permissions/add_member_to_all_workspaces.rb
349
+ - lib/neetob/cli/workspace_permissions/commands.rb
350
+ - lib/neetob/cli/workspace_permissions/permission_helpers.rb
345
351
  - lib/neetob/exception_handler.rb
346
352
  - lib/neetob/utils.rb
347
353
  - lib/neetob/version.rb