drone-hunter 0.1.1 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 861970148bcea4b9401487878b533fb2547945f8f73805442411d0d8400c9530
4
- data.tar.gz: be66196505c7ec0c23a0a510b3f75c991f78bede3cb8f51bf5db4c545183f862
3
+ metadata.gz: 37b22b2b6edd120ad5b68d96f69e4dbfea113c69aca6c605b6f2b72405d11d51
4
+ data.tar.gz: b1f6c55a257b4be6367e2dbfef217f7191e50413bead70043e7e1d068f2cd6c8
5
5
  SHA512:
6
- metadata.gz: f4cc781d6f2385f62c54626e56e31909f28d7aa223a7ed943b10bbb158b4f35f3837e9492089d20da7ee18b19596faf92f602c2a4b9cdb48ac706b33ebecbe35
7
- data.tar.gz: 2d882f2bb9b1b7015f7e57388371e24bdaebfac2b5b3471c8da0f4f395587ba5b7de82cd6dbee57fc4b4df3c24f019b7f75d573734a58d6c9b768ee4d6cc1193
6
+ metadata.gz: acf5462f956910eb483b81b9b19467e05ca7b86d50e52a6015d90d108d3a6c2823b15acc1c02f033844ce6961b8f3bdb97aa3d6c61a5789488b94ac4f63328b4
7
+ data.tar.gz: 05d681deef5afc54234bd4dfee9600666a3deb8bffb4318af0f068e8b6f1b969156c4c83897728dc5f0827d36e1df922eafd63ed67acbcad083dec13d801b101
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "bundler" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,72 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "master" ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ "master" ]
20
+ schedule:
21
+ - cron: '35 6 * * 3'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'ruby' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+
52
+ # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53
+ # queries: security-extended,security-and-quality
54
+
55
+
56
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57
+ # If this step fails, then you should remove it and run the build manually (see below)
58
+ - name: Autobuild
59
+ uses: github/codeql-action/autobuild@v2
60
+
61
+ # ℹ️ Command-line programs to run using the OS shell.
62
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63
+
64
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
65
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66
+
67
+ # - run: |
68
+ # echo "Run, Build Application using script"
69
+ # ./location_of_script_within_repo/buildscript.sh
70
+
71
+ - name: Perform CodeQL Analysis
72
+ uses: github/codeql-action/analyze@v2
@@ -0,0 +1,45 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ pull_request:
7
+ branches: [ "master" ]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build + Publish
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ packages: write
16
+
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Ruby 2.6
20
+ uses: actions/setup-ruby@v1
21
+ with:
22
+ ruby-version: 2.6.x
23
+
24
+ - name: Publish to GPR
25
+ run: |
26
+ mkdir -p $HOME/.gem
27
+ touch $HOME/.gem/credentials
28
+ chmod 0600 $HOME/.gem/credentials
29
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
30
+ gem build *.gemspec
31
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
32
+ env:
33
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
34
+ OWNER: ${{ github.repository_owner }}
35
+
36
+ # - name: Publish to RubyGems
37
+ # run: |
38
+ # mkdir -p $HOME/.gem
39
+ # touch $HOME/.gem/credentials
40
+ # chmod 0600 $HOME/.gem/credentials
41
+ # printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
42
+ # gem build *.gemspec
43
+ # gem push *.gem
44
+ # env:
45
+ # GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Change Log
2
+
3
+ ## 0.2.0
4
+
5
+ - [config] added `--github-auto-paginate` option if you want to turn this off for some reason.
6
+ - [feature] added `--output-normalize` option to remove cosmetic differences from dronefiles.
7
+
8
+ ## 0.1.1
9
+
10
+ - [fix] `--output-format=files` actually works now.
11
+
12
+ ## 0.1.0
13
+
14
+ - initial release
data/README.md CHANGED
@@ -76,6 +76,12 @@ drone-hunter.output/rancherlabs/support-tools/.drone.yml
76
76
 
77
77
  The only limits are your imagination (and the GitHub API Rate Limit).
78
78
 
79
+ ## Output Normalization
80
+
81
+ As of `0.2.0`, you can pass use the `--output-normalize` option to
82
+ remove formatting differences in the dronefiles. This reduces false
83
+ negatives when trying to identify which files are the same.
84
+
79
85
  ## License
80
86
 
81
87
  `drone-hunter` is available under the [MIT License](https://tldrlegal.com/license/mit-license). See `LICENSE.txt` for the full text.
data/bin/drone-hunter CHANGED
@@ -49,6 +49,15 @@ def log_level_from(input)
49
49
  end
50
50
  end
51
51
 
52
+ # accepts the same values as YAML: https://yaml.org/type/bool.html
53
+ def boolean_from(input)
54
+ case input
55
+ when /1|true|yes|on|enabled?/i then true
56
+ when /0|false|no|off|disabled?/i then false
57
+ else raise NotImplementedError
58
+ end
59
+ end
60
+
52
61
  #########################
53
62
  # Default Configuration #
54
63
  #########################
@@ -59,7 +68,7 @@ config = {
59
68
  dir: File.expand_path(ENV.fetch("DRONE_HUNTER_CACHE_DIR", './drone-hunter.cache'))
60
69
  },
61
70
  github: {
62
- auto_paginate: true,
71
+ auto_paginate: boolean_from(ENV.fetch("DRONE_HUNTER_GITHUB_AUTO_PAGINATE", "true")),
63
72
  access_token: github_access_token_from_environment
64
73
  },
65
74
  log: {
@@ -68,6 +77,7 @@ config = {
68
77
  output: {
69
78
  format: output_format_from(ENV.fetch("DRONE_HUNTER_OUTPUT_FORMAT", "json")),
70
79
  path: File.expand_path(ENV.fetch("DRONE_HUNTER_OUTPUT_PATH", "./drone-hunter.output")),
80
+ normalize: boolean_from(ENV.fetch("DRONE_HUNTER_OUTPUT_NORMALIZE", "false")),
71
81
  }
72
82
  }
73
83
 
@@ -76,11 +86,13 @@ config = {
76
86
  ################################
77
87
 
78
88
  OptionParser.new do |options|
79
- options.on("-C", "--cache-dir=DIR", "env: DRONE_HUNTER_CACHE_DIR") { |argument| config[:cache][:dir] = File.expand_path(argument) }
80
- options.on( "--github-access-token=TOKEN", "env: DRONE_HUNTER_GITHUB_ACCESS_TOKEN") { |argument| config[:github][:access_token] = argument }
81
- options.on("-L", "--log-level=LEVEL", "env: DRONE_HUNTER_LOG_LEVEL") { |argument| config[:log][:level] = log_level_from(argument) }
82
- options.on("-o", "--output-format=FORMAT", "env: DRONE_HUNTER_OUTPUT_FORMAT") { |argument| config[:output][:format] = output_format_from(argument) }
83
- options.on("-p", "--output-path=PATH", "env: DRONE_HUNTER_OUTPUT_PATH") { |argument| config[:output][:path] = File.expand_path(argument) }
89
+ options.on("-C", "--cache-dir=DIR", "env: DRONE_HUNTER_CACHE_DIR") { |argument| config[:cache][:dir] = File.expand_path(argument) }
90
+ options.on( "--github-access-token=TOKEN", "env: DRONE_HUNTER_GITHUB_ACCESS_TOKEN") { |argument| config[:github][:access_token] = argument }
91
+ options.on( "--[no-]github-auto-paginate", "env: DRONE_HUNTER_GITHUB_AUTO_PAGINATE") { |argument| config[:github][:auto_paginate] = argument}
92
+ options.on("-L", "--log-level=LEVEL", "env: DRONE_HUNTER_LOG_LEVEL") { |argument| config[:log][:level] = log_level_from(argument) }
93
+ options.on("-o", "--output-format=FORMAT", "env: DRONE_HUNTER_OUTPUT_FORMAT") { |argument| config[:output][:format] = output_format_from(argument) }
94
+ options.on("-p", "--output-path=PATH", "env: DRONE_HUNTER_OUTPUT_PATH") { |argument| config[:output][:path] = File.expand_path(argument) }
95
+ options.on("-N", "--[no-]output-normalize", "env: DRONE_HUNTER_OUTPUT_NORMALIZE") { |argument| config[:output][:normalize] = argument }
84
96
  end.parse!
85
97
 
86
98
  #################
@@ -128,7 +140,14 @@ if config[:hacking]
128
140
  require "pry"
129
141
  binding.pry
130
142
  else
131
- hunt.dronefiles.then do |dronefiles|
143
+ hunt.dronefiles.each do |dronefile|
144
+ if config[:output][:normalize]
145
+ require "yaml"
146
+ original = dronefile["content"]
147
+ normalized = YAML.dump(YAML.load(original))
148
+ dronefile["content"] = normalized
149
+ end
150
+ end.then do |dronefiles|
132
151
  case config[:output][:format]
133
152
  when :JSON
134
153
  require "json"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drone-hunter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Olstrom
@@ -57,6 +57,10 @@ executables:
57
57
  extensions: []
58
58
  extra_rdoc_files: []
59
59
  files:
60
+ - ".github/dependabot.yml"
61
+ - ".github/workflows/codeql-analysis.yml"
62
+ - ".github/workflows/gem-push.yml"
63
+ - CHANGELOG.md
60
64
  - Gemfile
61
65
  - LICENSE.txt
62
66
  - README.md