claws-scan 0.7.5 → 0.9.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: '088da1fb246e5843261993812e1b89125eba56e5892628516969d496048fef7e'
4
- data.tar.gz: 82c7a7674fa590a5feda1511f4b3f43970401ec5b2c9898f7c7c859e0805d0df
3
+ metadata.gz: 5f4c3263217e12165f1f7c89c402a4e9cf1085ccfca4d4ab8316d9693569a8bb
4
+ data.tar.gz: f1bab1dd428690f47e8e81d97892e47d9cd2764233eb93c44f0f704f030e86e0
5
5
  SHA512:
6
- metadata.gz: 6385a23ac3b074ded87e7b761e4fdd25a7b19770b63b460ee1192664972b9da20dfabc8f6e80e94f327e3b2a6016bce5d996c02dcefae8831ae9bd43d4d10abd
7
- data.tar.gz: 46adc628c3b02d052d601540d9421e01c70f343a41982593795c149b448ecffdde64c6fc704a6526a5c014237047b5518d72373cc0e05d5197e67d53b0682776
6
+ metadata.gz: 766245e17380af395539025794b2461be4be0aa54ab20e8b3fbfb1128032c1228155e398d25bfb6295bd1050ca30d708a3408107b27d006874fa85fd94befc46
7
+ data.tar.gz: 6ba57d659080d29788dd8de41ff88f4aa6bacb7b2ba2ef0332714e85c13dd111ebe6745bf4b894ce3e905ced0a1cd2a688d200c33447ad06a728633bf8200943
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.0
2
+ TargetRubyVersion: 3.2.3
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- claws-scan (0.7.5)
4
+ claws-scan (0.9.0)
5
5
  equation (~> 0.6)
6
6
  pry
7
7
  slop (~> 4.9)
data/README.md CHANGED
@@ -8,6 +8,82 @@ This is in contrast to common static analysis tools that achieve this by requiri
8
8
 
9
9
  While it's important to be able to easily write a Rule, it's just as important (if not more!) to write good tests for them. Like with Rubocop, Claws comes with a couple RSpec helpers that makes it easy to write test cases. Test cases are simply example Workflows that exercise a Rule's expressions, ensuring that a modification to a Rule can't accidentally affect its ability to detect known bad content.
10
10
 
11
+ ## Getting Started
12
+
13
+ Claws is written in Ruby and distributed as a Ruby Gem, so you can install it using `gem`. Just point it at the [example configuration](example-config.yml) file and you should be good to go.
14
+
15
+ For one off scans, you can just follow these commands:
16
+ ```
17
+ # Install claws
18
+ $ gem install claws-scan
19
+
20
+ # Optionally, specify a version
21
+ $ gem install claws-scan -v 0.7.5
22
+
23
+ # Scan a Github Action file
24
+ analyze -c example_config.yml -t .github/workflows/ci.yml
25
+ ```
26
+
27
+ If you'd like to integrate this into your workflow like we have, this should be enough to get you started.
28
+
29
+ ```yaml
30
+ name: Workflow Static Analyzer
31
+
32
+ on:
33
+ pull_request:
34
+ branches:
35
+ - main
36
+
37
+ jobs:
38
+ build:
39
+ name: Analyze Github Workflows
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - name: Set Up Ruby
43
+ uses: ruby/setup-ruby@d8d83c3960843afb664e821fed6be52f37da5267 # v1.231.0
44
+ with:
45
+ ruby-version: '3.0'
46
+ # Grab your configuration file however makes sense for you
47
+ # We keep ours in a separate Github repo.
48
+ - name: Set Up Claws Config
49
+ run: |
50
+ echo ... > /tmp/claws-config.yml
51
+ # Optional, useful if you want Claws to run shellcheck for you
52
+ - name: Set Up Shellcheck
53
+ run: |
54
+ sudo apt-get update
55
+ sudo apt-get install -y shellcheck
56
+ - uses: actions/checkout@v4
57
+ with:
58
+ fetch-depth: 0
59
+ - name: Set Up Claws
60
+ run: |
61
+ gem install claws-scan -v 0.7.5
62
+ - name: Analyze Workflows
63
+ run: |
64
+ #!/bin/bash
65
+
66
+ # Collect all files in the .github/workflows directory
67
+ workflow_files=$(find .github/workflows -type f)
68
+
69
+ # Exit early if there are no workflow files
70
+ if [[ -z "$workflow_files" ]]; then
71
+ echo "No workflow files found in .github/workflows"
72
+ exit 0
73
+ fi
74
+
75
+ flags=()
76
+
77
+ # Iterate over each workflow file
78
+ while IFS= read -r file; do
79
+ echo "Processing $file"
80
+ flags+=("-t" "$file")
81
+ done <<< "$workflow_files"
82
+
83
+ # Run the analyze command with all gathered flags
84
+ analyze -f github -c /tmp/claws-config.yml "${flags[@]}"
85
+ ```
86
+
11
87
  ## Built In Rules
12
88
 
13
89
  These are all the rules that come out of the box with Claws. They can all be found in [the rules subdirectory](https://github.com/Betterment/claws/tree/main/lib/claws/rule), and some of them have configuration options.
@@ -204,6 +280,18 @@ Shellcheck is a great tool for dealing with bugs or otherwise unintended effects
204
280
 
205
281
  This rule flags workflows that request write access to specific unusual permissions. While this rule cannot flag how these permissions are exercised, it serves as a warning to code reviewers that if these permissions are requested, the way they are used should be scrutinized. A reviewer may find that a permission is left over from testing and no longer needed, or that a specific permission was never needed.
206
282
 
283
+ ### CheckoutWithStaticCredentials
284
+
285
+ This rule flags any uses of `actions/checkout` using static credentials. Using static credentials can pose a risk because these credentials are typically not auditable and can be tricky to rotate. In the event of an incident where they are leaked, incident response to determine the scope of impact may be tough.
286
+
287
+ Where possible, the default `$GITHUB_TOKEN` should be used. Its settings can be configured directly from within the workflow. Check [the official documentation](https://docs.github.com/en/actions/tutorials/authenticate-with-github_token#modifying-the-permissions-for-the-github_token) for more information on how to do this.
288
+
289
+ If you are using a deploy key via SSH to access a package or otherwise an artifact from another repository, you can instead configure the repository to grant it access explicitly to that other repository. This will give the default `$GITHUB_TOKEN` access to that repository without needing to use a deploy key. To learn more about this, [check out the official documentation](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility). This is safer than a static deploy key because the credential is short lived and access can be audited.
290
+
291
+ If you need a Github Token to perform some authenticated action where the default `$GITHUB_TOKEN` doesn't do what you need, consider setting up a Github App and using [`actions/create-github-app-token`](https://github.com/actions/create-github-app-token). This will generate a short lived access token, and using an app creates a useful audit trail for what this access token can actually do. Then, use this token in just the build steps where it's needed.
292
+
293
+ In some cases, a static access token or deploy key may still be necessary, especially for APIs that are not yet supported by Github App Tokens. In these cases, make sure to limit the scope of the access token to the bare minimum necessary to function.
294
+
207
295
  ### UnapprovedRunners
208
296
 
209
297
  This rule flags workflows that use runners that they might not need or should not use. This can come in handy when an organization has available self hosted or otherwise expensive runners but wants to be particular about when they're used.
data/bin/analyze CHANGED
@@ -5,7 +5,7 @@ require "claws"
5
5
  require "slop"
6
6
 
7
7
  flags = Slop::Options.new
8
- flags.banner = "usage: process [options] ..."
8
+ flags.banner = "usage: analyze [options] ..."
9
9
  flags.separator ""
10
10
  flags.separator "Options:"
11
11
  flags.string "-c", "--config", required: true
@@ -0,0 +1,17 @@
1
+ Enabled:
2
+ NoContainers:
3
+ approved_images: ["ubuntu-latest"]
4
+ SpecialPermissions:
5
+ EmptyName:
6
+ RiskyTriggers:
7
+ UnapprovedRunners:
8
+ allowed_runners: ["ubuntu-latest", "macos-latest"]
9
+ CommandInjection:
10
+ AutomaticMerge:
11
+ UnpinnedAction:
12
+ trusted_authors: ["actions"]
13
+ UnsafeCheckout:
14
+ InheritedSecrets:
15
+ BulkPermissions:
16
+ Shellcheck:
17
+ shellcheck_bin: "/usr/bin/shellcheck"
@@ -43,10 +43,10 @@ module Claws
43
43
  @detections.each do |detection|
44
44
  detection.on_workflow.each do |rule|
45
45
  violation = run_detection(
46
- filename: filename,
47
- detection: detection,
48
- rule: rule,
49
- workflow: workflow
46
+ filename:,
47
+ detection:,
48
+ rule:,
49
+ workflow:
50
50
  )
51
51
 
52
52
  violations << violation if violation
@@ -58,7 +58,7 @@ module Claws
58
58
  expression: rule[:expression],
59
59
  values: {
60
60
  data: detection.data,
61
- workflow: workflow
61
+ workflow:
62
62
  }
63
63
  )
64
64
  end
@@ -72,11 +72,11 @@ module Claws
72
72
  @detections.each do |detection|
73
73
  detection.on_job.each do |rule|
74
74
  violation = run_detection(
75
- filename: filename,
76
- detection: detection,
77
- rule: rule,
78
- workflow: workflow,
79
- job: job
75
+ filename:,
76
+ detection:,
77
+ rule:,
78
+ workflow:,
79
+ job:
80
80
  )
81
81
 
82
82
  violations << violation if violation
@@ -88,8 +88,8 @@ module Claws
88
88
  expression: rule[:expression],
89
89
  values: {
90
90
  data: detection.data,
91
- workflow: workflow,
92
- job: job
91
+ workflow:,
92
+ job:
93
93
  }
94
94
  )
95
95
  end
@@ -104,12 +104,12 @@ module Claws
104
104
  @detections.each do |detection|
105
105
  detection.on_step.each do |rule|
106
106
  violation = run_detection(
107
- filename: filename,
108
- detection: detection,
109
- rule: rule,
110
- workflow: workflow,
111
- job: job,
112
- step: step
107
+ filename:,
108
+ detection:,
109
+ rule:,
110
+ workflow:,
111
+ job:,
112
+ step:
113
113
  )
114
114
 
115
115
  violations << violation if violation
@@ -121,9 +121,9 @@ module Claws
121
121
  expression: rule[:expression],
122
122
  values: {
123
123
  data: detection.data,
124
- workflow: workflow,
125
- job: job,
126
- step: step
124
+ workflow:,
125
+ job:,
126
+ step:
127
127
  }
128
128
  )
129
129
  end
@@ -137,19 +137,19 @@ module Claws
137
137
  def run_detection(filename:, detection:, rule:, workflow:, job: nil, step: nil) # rubocop:disable Metrics/ParameterLists
138
138
  violation = if rule.is_a? Symbol
139
139
  get_dynamic_violation(
140
- detection: detection,
140
+ detection:,
141
141
  method: rule,
142
- workflow: workflow,
143
- job: job,
144
- step: step
142
+ workflow:,
143
+ job:,
144
+ step:
145
145
  )
146
146
  else
147
147
  get_static_violations(
148
- detection: detection,
149
- rule: rule,
150
- workflow: workflow,
151
- job: job,
152
- step: step
148
+ detection:,
149
+ rule:,
150
+ workflow:,
151
+ job:,
152
+ step:
153
153
  )
154
154
  end
155
155
 
@@ -164,18 +164,18 @@ module Claws
164
164
  def get_dynamic_violation(detection:, method:, workflow:, job:, step:)
165
165
  detection.send(
166
166
  method,
167
- workflow: workflow,
168
- job: job,
169
- step: step
167
+ workflow:,
168
+ job:,
169
+ step:
170
170
  )
171
171
  end
172
172
 
173
173
  def get_static_violations(rule:, detection:, workflow:, job:, step:)
174
174
  result = rule[:expression].eval_with(values: {
175
175
  data: detection.data,
176
- workflow: workflow,
177
- job: job,
178
- step: step
176
+ workflow:,
177
+ job:,
178
+ step:
179
179
  })
180
180
 
181
181
  return unless result
@@ -14,6 +14,7 @@ class BaseRule
14
14
  endswith: ->(string, needle) { string.to_s.end_with? needle },
15
15
  difference: ->(arr1, arr2) { arr1.difference arr2 },
16
16
  intersection: ->(arr1, arr2) { arr1.intersection arr2 },
17
+ get_key: ->(arr, key) { (arr || {}).fetch(key, nil) },
17
18
  count: ->(n) { n.length }
18
19
  }
19
20
  )
@@ -45,23 +46,23 @@ class BaseRule
45
46
  end
46
47
 
47
48
  def self.on_workflow(value, highlight: nil, debug: false)
48
- (@on_workflow ||= []) << extract_value(value, highlight: highlight, debug: debug)
49
+ (@on_workflow ||= []) << extract_value(value, highlight:, debug:)
49
50
  end
50
51
 
51
52
  def self.on_job(value, highlight: nil, debug: false)
52
53
  highlight = highlight.to_s unless highlight.nil?
53
- (@on_job ||= []) << extract_value(value, highlight: highlight, debug: debug)
54
+ (@on_job ||= []) << extract_value(value, highlight:, debug:)
54
55
  end
55
56
 
56
57
  def self.on_step(value, highlight: nil, debug: false)
57
58
  highlight = highlight.to_s unless highlight.nil?
58
- (@on_step ||= []) << extract_value(value, highlight: highlight, debug: debug)
59
+ (@on_step ||= []) << extract_value(value, highlight:, debug:)
59
60
  end
60
61
 
61
62
  def self.extract_value(value, highlight: nil, debug: false)
62
63
  case value
63
64
  when String
64
- { expression: parse_rule(value), highlight: highlight, debug: debug }
65
+ { expression: parse_rule(value), highlight:, debug: }
65
66
  when Symbol
66
67
  value
67
68
  else
@@ -18,7 +18,9 @@ module Psych
18
18
  class ToRuby
19
19
  def accept(target)
20
20
  s = super(target)
21
- if target.respond_to?(:line) and ![TrueClass, FalseClass, NilClass, Integer].include? s.class
21
+
22
+ # types that we cannot monkey patch into holding line information
23
+ if target.respond_to?(:line) and ![TrueClass, FalseClass, NilClass, Integer, Float].include? s.class
22
24
  s.instance_eval do
23
25
  extend(Locatable)
24
26
  end
@@ -49,7 +51,9 @@ module Psych
49
51
  key.line = 0 if key.respond_to? :line and key.line.nil?
50
52
  key.line += 1 if key.respond_to? :line
51
53
  key.freeze
52
- if [TrueClass, FalseClass, NilClass, Integer].include? key.class
54
+
55
+ # types that we cannot monkey patch into holding line information
56
+ if [TrueClass, FalseClass, NilClass, Integer, Float].include? key.class
53
57
  val.line = 0 if val.respond_to? :line and val.line.nil?
54
58
  val.line += 1 if val.respond_to? :line
55
59
  end
@@ -0,0 +1,38 @@
1
+ module Claws
2
+ module Rule
3
+ class CheckoutWithStaticCredentials < BaseRule
4
+ description <<~DESC
5
+ Avoid using static credentials like deploy keys, SSH keys, or personal access
6
+ tokens to clone other repositories. Static credentials can be tricky to audit
7
+ and rotate, making them risky to hold onto, especially in the event of an
8
+ incident where they may be leaked.
9
+
10
+ Either grant your repository access directly to other repositories, or use a
11
+ Github App to generate a short lived access token.
12
+
13
+ For more information:
14
+ https://github.com/betterment/claws/blob/main/README.md#checkoutwithstaticcredentials
15
+ DESC
16
+
17
+ on_step %(
18
+ $step.meta.action.name == "actions/checkout" &&
19
+ (
20
+ get_key($step.with, "ssh-key") =~ "{{.*secrets\..*" ||
21
+ get_key($step.with, "ssh-key") =~ "{{.*env\..*" ||
22
+ get_key($step.with, "ssh-key") =~ "{{.*vars\..*" ||
23
+ get_key($step.with, "ssh-key") =~ ".*-----BEGIN.*"
24
+ )
25
+ ), highlight: "with.ssh-key"
26
+
27
+ on_step %(
28
+ $step.meta.action.name == "actions/checkout" &&
29
+ (
30
+ get_key($step.with, "token") =~ "{{.*secrets\..*" ||
31
+ get_key($step.with, "token") =~ "{{.*env\..*" ||
32
+ get_key($step.with, "token") =~ "{{.*vars\..*" ||
33
+ get_key($step.with, "token") =~ "gh[a-z]_.*"
34
+ )
35
+ ), highlight: "with.token"
36
+ end
37
+ end
38
+ end
@@ -8,7 +8,7 @@ module Claws
8
8
  https://github.com/betterment/claws/blob/main/README.md#commandinjection
9
9
  DESC
10
10
 
11
- on_step '$step.run =~ ".*{{[ ]+.*(github.event|inputs).*}}.*"', highlight: "run"
11
+ on_step '$step.run =~ ".*{{.*(github\.event|inputs)\..*}}.*"', highlight: "run"
12
12
  end
13
13
  end
14
14
  end
data/lib/claws/rule.rb CHANGED
@@ -11,3 +11,4 @@ require "claws/rule/inherited_secrets"
11
11
  require "claws/rule/command_injection"
12
12
  require "claws/rule/bulk_permissions"
13
13
  require "claws/rule/shellcheck"
14
+ require "claws/rule/checkout_with_static_credentials"
data/lib/claws/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Claws
4
- VERSION = "0.7.5"
4
+ VERSION = "0.9.0"
5
5
  end
@@ -173,7 +173,7 @@ class Workflow
173
173
  name, version = action.split("@", 2)
174
174
  author = name.split("/", 2)[0]
175
175
  local = author == "."
176
- { type: "action", name: name, author: author, version: version, local: local }
176
+ { type: "action", name:, author:, version:, local: }
177
177
  end
178
178
 
179
179
  def extract_container_info_from_job(job)
@@ -195,8 +195,8 @@ class Workflow
195
195
 
196
196
  {
197
197
  type: "container",
198
- image: image,
199
- version: version,
198
+ image:,
199
+ version:,
200
200
  full: "#{image}:#{version}"
201
201
  }
202
202
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claws-scan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Omar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-07 00:00:00.000000000 Z
11
+ date: 2025-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equation
@@ -85,22 +85,7 @@ files:
85
85
  - Rakefile
86
86
  - bin/analyze
87
87
  - config.yml
88
- - corpus/automerge_via_action.yml
89
- - corpus/automerge_via_cli.yml
90
- - corpus/build-docker-image-run-drc-for-cell-gds-using-magic.yml
91
- - corpus/cmd.yml
92
- - corpus/container.yml
93
- - corpus/container_docker.yml
94
- - corpus/dispatch_command_injection.yml
95
- - corpus/inherit_secrets.yml
96
- - corpus/nameless.yml
97
- - corpus/permissions.yml
98
- - corpus/ruby.yml
99
- - corpus/shellcheck.yml
100
- - corpus/unsafe_checkout_code_execution.yml
101
- - corpus/unsafe_checkout_token_leak.yml
102
- - corpus/unscoped_secrets.yml
103
- - github_action.yml
88
+ - example-config.yml
104
89
  - lib/claws.rb
105
90
  - lib/claws/application.rb
106
91
  - lib/claws/base_rule.rb
@@ -113,6 +98,7 @@ files:
113
98
  - lib/claws/rule.rb
114
99
  - lib/claws/rule/automatic_merge.rb
115
100
  - lib/claws/rule/bulk_permissions.rb
101
+ - lib/claws/rule/checkout_with_static_credentials.rb
116
102
  - lib/claws/rule/command_injection.rb
117
103
  - lib/claws/rule/empty_name.rb
118
104
  - lib/claws/rule/inherited_secrets.rb
@@ -139,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
125
  requirements:
140
126
  - - ">="
141
127
  - !ruby/object:Gem::Version
142
- version: '3.0'
128
+ version: '3.2'
143
129
  required_rubygems_version: !ruby/object:Gem::Requirement
144
130
  requirements:
145
131
  - - ">="
@@ -1,28 +0,0 @@
1
- name: Automerge via Github Action
2
-
3
- on:
4
- pull_request:
5
- types:
6
- - labeled
7
- - unlabeled
8
- - synchronize
9
- - opened
10
- - edited
11
- - ready_for_review
12
- - reopened
13
- - unlocked
14
- pull_request_review:
15
- types:
16
- - submitted
17
- check_suite:
18
- types:
19
- - completed
20
- status: {}
21
-
22
- jobs:
23
- automerge:
24
- runs-on: ubuntu-latest
25
- steps:
26
- - id: automerge
27
- name: automerge
28
- uses: "pascalgn/automerge-action@v0.15.5"
@@ -1,14 +0,0 @@
1
- name: Automerge Non-code Changes
2
- on:
3
- push:
4
- paths: ['**.txt']
5
-
6
- permissions:
7
- contents: read
8
-
9
- jobs:
10
- merge:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: Merge pull request
14
- run: gh pr merge ${{ steps.create_pull_request.outputs.pull-request-number }} --squash --auto --delete-branch
@@ -1,170 +0,0 @@
1
- # Copyright 2021 SkyWater PDK Authors
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- #
15
- # SPDX-License-Identifier: Apache 2.0
16
-
17
- name: Build Docker Image for Run DRC for cell GDS (using Magic) Action
18
-
19
- on:
20
- workflow_dispatch:
21
- push:
22
- pull_request_target:
23
-
24
-
25
- permissions:
26
- contents: read
27
-
28
-
29
- jobs:
30
-
31
- # FIXME: Remove once GitHub Container Registry is working.
32
- # docker.pkg.github.com doesn't support buildx built packages, use
33
- # docker/build-push-action instead.
34
- build-github-package:
35
- name: "Building Docker GitHub Package."
36
-
37
- runs-on: ubuntu-latest
38
-
39
- permissions:
40
- packages: write # ${{ github.event_name == "push" || github.event_name == "workflow_dispatch" }}
41
-
42
- steps:
43
- - name: Checkout code
44
- uses: actions/checkout@v2
45
- with:
46
- # Always clone the full depth so git-describe works.
47
- fetch-depth: 0
48
- submodules: true
49
-
50
- - name: Set Action Name
51
- run: echo "ACTION_NAME=run-drc-for-cell-gds-using-magic" >> $GITHUB_ENV
52
-
53
- - name: Build container image
54
- uses: docker/build-push-action@v1
55
- with:
56
- registry: docker.pkg.github.com
57
- username: ${{ github.repository_owner }}
58
- password: ${{ github.token }}
59
- repository: ${{ github.repository }}/${{ env.ACTION_NAME }}
60
- path: ${{ env.ACTION_NAME }}
61
- tag_with_ref: true
62
- tag_with_sha: true
63
- add_git_labels: true
64
- push: ${{ startsWith(github.ref, 'refs/heads/') }}
65
-
66
-
67
- build-docker-image:
68
- name: "Building image."
69
-
70
- runs-on: ubuntu-latest
71
-
72
- # Run a local registry
73
- services:
74
- registry:
75
- image: registry:2
76
- ports:
77
- - 5000:5000
78
-
79
- steps:
80
-
81
- - name: Dump context
82
- uses: crazy-max/ghaction-dump-context@v1
83
-
84
- - name: Checkout code
85
- uses: actions/checkout@v2
86
- with:
87
- # Always clone the full depth so git-describe works.
88
- fetch-depth: 0
89
- submodules: true
90
-
91
- - name: Set Action Name
92
- run: echo "ACTION_NAME=run-drc-for-cell-gds-using-magic" >> $GITHUB_ENV
93
-
94
- - name: Detect Push To Config
95
- id: push_to
96
- shell: python
97
- env:
98
- HAS_GCR_JSON_KEY: ${{ !!(secrets.GCR_JSON_KEY) }}
99
- run: |
100
- import os
101
- gh_event = os.environ['GITHUB_EVENT_NAME']
102
-
103
- i = []
104
- print("Adding local service.")
105
- i.append("localhost:5000/${{ env.ACTION_NAME }}")
106
-
107
- if "${{ env.HAS_GCR_JSON_KEY }}":
108
- print("Adding Google Container Repository (gcr.io)")
109
- i.append("gcr.io/skywater-pdk/actions/${{ env.ACTION_NAME }}")
110
-
111
- #print("Adding GitHub Container Repository (ghcr.io)")
112
- #i.append("ghcr.io/${{ github.repository }}/${{ env.ACTION_NAME }}")
113
-
114
- l = ",".join(i)
115
- print("Final locations:", repr(l))
116
- print("::set-output name=images::{}".format(l))
117
-
118
- - name: Docker meta
119
- id: docker_meta
120
- uses: docker/metadata-action@v3
121
- with:
122
- images: ${{ steps.push_to.outputs.images }}
123
- tags: |
124
- type=ref,event=tag
125
- type=ref,event=pr
126
- type=ref,event=branch
127
- type=sha
128
- type=sha,format=long
129
-
130
- - name: Set up QEMU
131
- uses: docker/setup-qemu-action@v1
132
-
133
- - name: Set up Docker Buildx
134
- uses: docker/setup-buildx-action@v1
135
- with:
136
- driver-opts: network=host
137
-
138
- - name: Login to Google Container Registry
139
- if: ${{ contains(steps.push_to.outputs.images, 'gcr.io') }}
140
- uses: docker/login-action@v1
141
- with:
142
- registry: gcr.io
143
- username: _json_key
144
- password: ${{ secrets.GCR_JSON_KEY }}
145
-
146
- - name: Login to GitHub Container Registry
147
- if: ${{ contains(steps.push_to.outputs.images, 'ghcr.io') }}
148
- uses: docker/login-action@v1
149
- with:
150
- username: ${{ github.repository_owner }}
151
- password: ${{ github.token }}
152
- registry: ghcr.io
153
-
154
- - name: Build and push
155
- uses: docker/build-push-action@v2
156
- id: docker_build
157
- with:
158
- context: ${{ env.ACTION_NAME }}
159
- file: ${{ env.ACTION_NAME }}/Dockerfile
160
- push: true
161
- tags: |
162
- ${{ steps.docker_meta.outputs.tags }}
163
- localhost:5000/${{ env.ACTION_NAME }}:latest
164
- labels: ${{ steps.docker_meta.outputs.labels }}
165
-
166
- - name: Inspect
167
- run: docker buildx imagetools inspect localhost:5000/${{ env.ACTION_NAME }}:latest
168
-
169
- - name: Image digest
170
- run: echo ${{ steps.docker_build.outputs.digest }}
data/corpus/cmd.yml DELETED
@@ -1,14 +0,0 @@
1
- # INSECURE
2
-
3
- on: issue_comment
4
- name: IssueOps - Demo
5
- jobs:
6
- act-on-issue:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - name: Checkout
10
- uses: actions/checkout@v1
11
- - name: Reset demo if a demo or reset issue was opened
12
- run: ./scripts/reset-demo.sh "${{ github.event.issue.body }}" "${{ github.event.issue.number }}"
13
- env:
14
- GITHUB_COM_TOKEN: ${{ secrets.GITHUB_TOKEN }}
data/corpus/container.yml DELETED
@@ -1,19 +0,0 @@
1
- name: CI
2
- on:
3
- push:
4
- branches: [ main ]
5
- jobs:
6
- container-test-job:
7
- runs-on: ubuntu-latest
8
- container:
9
- image: node:14.16
10
- env:
11
- NODE_ENV: development
12
- ports:
13
- - 80
14
- volumes:
15
- - my_docker_volume:/volume_mount
16
- options: --cpus 1
17
- steps:
18
- - name: Check for dockerenv file
19
- run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
@@ -1,9 +0,0 @@
1
- name: CI
2
- on:
3
- push:
4
- branches: [ main ]
5
- jobs:
6
- use_image:
7
- steps:
8
- - name: My first step
9
- uses: docker://alpine:3.8
@@ -1,17 +0,0 @@
1
- name: Dispatch Me
2
- on:
3
- workflow_dispatch:
4
- inputs:
5
- name:
6
- description: 'Who I should say hello to'
7
- required: true
8
-
9
- jobs:
10
- greet:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - name: Checkout
14
- uses: actions/checkout@v1
15
- - name: Reset demo if a demo or reset issue was opened
16
- run: ./scripts/greet.sh "${{ github.event.inputs.name }}"
17
-
@@ -1,20 +0,0 @@
1
- on: [workflow_call]
2
- name: yea
3
- jobs:
4
- rake:
5
- runs-on: ubuntu-latest
6
- secrets: inherit
7
- steps:
8
- - name: Checkout
9
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
10
- with:
11
- ref: ${{ github.event.pull_request.head.sha }}
12
- # ignore: CommandInjection
13
- - name: test
14
- run: /bin/ls ${{ github.event.test }}
15
- - name: Build
16
- run: rake
17
- env:
18
- GITHUB_TOKEN: ${{ github.token }}
19
- YOINK: ${{ secrets.FLAG }}
20
-
data/corpus/nameless.yml DELETED
@@ -1,11 +0,0 @@
1
- on: [push, pull_request, pull_request_target]
2
- jobs:
3
- test:
4
- runs-on: ubuntu-latest
5
- steps:
6
- - uses: actions/checkout@v3
7
- - uses: ruby/setup-ruby@v1
8
- with:
9
- ruby-version: '3.0' # Not needed with a .ruby-version file
10
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
11
- - run: bundle exec rake
@@ -1,19 +0,0 @@
1
- name: Deploy
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- permissions:
9
- packages: write
10
-
11
- jobs:
12
- build:
13
- runs-on: ubuntu-latest
14
- permissions:
15
- packages: write
16
- steps:
17
- - uses: action/checkout@v3
18
- - name: push
19
- run: rake release
data/corpus/ruby.yml DELETED
@@ -1,12 +0,0 @@
1
- name: My workflow
2
- on: [push, pull_request, pull_request_target]
3
- jobs:
4
- test:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - uses: actions/checkout@v3
8
- - uses: ruby/setup-ruby@v1
9
- with:
10
- ruby-version: '3.0' # Not needed with a .ruby-version file
11
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
12
- - run: bundle exec rake
@@ -1,12 +0,0 @@
1
- on: [push, pull_request, pull_request_target]
2
- jobs:
3
- test:
4
- runs-on: ubuntu-latest
5
- steps:
6
- - uses: actions/checkout@v3
7
- - uses: ruby/setup-ruby@v1
8
- - run: |
9
- x=$(ls -lah)
10
- if [[ $x == 2 ]]; then
11
- echo $x
12
- fi
@@ -1,21 +0,0 @@
1
- name: Unsafe Checkout that Leads to RCE
2
-
3
- on: [pull_request_target]
4
-
5
- jobs:
6
- build:
7
- name: Build
8
- runs-on: ubuntu-latest
9
- steps:
10
- # check out the attacker controlled branch with their code
11
- - uses: actions/checkout@v2
12
- with:
13
- ref: ${{ github.event.pull_request.head.sha }}
14
-
15
- # set up the environment and run specs
16
- # because Rakefile comes from the attacker's branch
17
- # we end up executing their code, even though they don't
18
- # control the command here
19
- - run: |
20
- rake setup
21
- rake spec
@@ -1,33 +0,0 @@
1
- name: Unsafe Checkout that can Leak Tokens
2
-
3
- on: pull_request_target
4
-
5
- jobs:
6
- release:
7
- runs-on: ubuntu-latest
8
- steps:
9
- # check out the attacker controlled branch
10
- - name: Checkout (depth 0)
11
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
12
- with:
13
- ref: ${{ github.event.pull_request.head.sha }}
14
-
15
- # grab the version number from the VERSION file
16
- # however... because we're getting the contents of the file
17
- # from the attacker's branch, and because git allows symlinks
18
- # the attacker can symlink VERSION to any other file on the system
19
- # to leak its contents.
20
- - name: Get PR Version
21
- id: version_number
22
- run: echo "::set-output name=version::$(cat VERSION)"
23
-
24
- # Dump the version number into a Github comment for everyone to see
25
- - name: Comment the new version
26
- uses: peter-evans/create-or-update-comment@v2
27
- with:
28
- issue-number: ${{ github.event.pull_request.number }}
29
- comment-author: 'github-actions[bot]'
30
- body: |
31
- Version was updated to
32
- ```${{ steps.version_number.outputs.version }}```
33
- bye now...
@@ -1,16 +0,0 @@
1
- on: [pull_request]
2
- name: yea
3
- jobs:
4
- rake:
5
- runs-on: ubuntu-latest
6
- steps:
7
- - name: Checkout
8
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
9
- with:
10
- ref: ${{ github.event.pull_request.head.sha }}
11
- - name: Build
12
- run: rake
13
- env:
14
- GITHUB_TOKEN: ${{ github.token }}
15
- YOINK: ${{ secrets.API_KEY }}
16
-
data/github_action.yml DELETED
@@ -1,36 +0,0 @@
1
- name: Workflow Static Analyzer
2
-
3
- on:
4
- pull_request:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- build:
10
- runs-on: ubuntu-latest
11
- name: Static Analyze
12
- steps:
13
- - name: Set Up Ruby
14
- uses: ruby/setup-ruby@v1
15
- with:
16
- ruby-version: '3.0'
17
- - uses: actions/checkout@v3
18
- with:
19
- fetch-depth: 0
20
- - name: Get PR diff Files
21
- uses: technote-space/get-diff-action@v5
22
- id: modified_actions
23
- with:
24
- PATTERNS: .github/workflows/*.y*ml
25
- - name: Set Up Claws
26
- run: |
27
- gem install --source "https://${{ secrets.BETTERMENT_GH_PACKAGES_PAT }}@rubygems.pkg.github.com/betterment" claws --version "0.1.4"
28
- - name: Analyze New/Changed Workflows
29
- run: |
30
- bungler_flags=""
31
- for workflow in ${{ env.GIT_DIFF }}
32
- do
33
- echo "$workflow"
34
- bungler_flags="-t $workflow $bungler_flags"
35
- done
36
- analyze -f github -c .claws-config.yml $bungler_flags