gitlab-secret_detection 0.20.0 → 0.20.2

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: 8cd95dc817999bb641642ef12f37c72cdf877e417caf728752e5d61cbae1bcd2
4
- data.tar.gz: 42d9ce659069690870f07310bc35d8e41aab5accc23f2d8a5eac094bac9e6bbe
3
+ metadata.gz: 6c4a46de83d50ad3fa7c06657f57435bc179487c7f32e72e62a770ac97225dea
4
+ data.tar.gz: 05244c00091e0d97fbeb5f49e2b7eefd6451ac77510da6f7a72f31f42f467607
5
5
  SHA512:
6
- metadata.gz: ed2fc3c749afe3be21fe16d1f05fd1d16511dd20a7bd77594b707bd99248ee96ed3c2fafc2e0ade16cbad99f7265ea0b8941d3021547b4c4d9f4363bfad31965
7
- data.tar.gz: f2a8d9e25d2ccf3a1f35afa23dffd01a21871d895f9bd0f7a4daffd430391067eabe305db230a575cdda41975eb926fa8c50a84914ab3d26b33d2703e58f597a
6
+ metadata.gz: 7d4918b73c28f2feb0d238be8f66689020a247eef62ade67c249c16ea1dc89620733070ce015356aa1f642c377d2b4b6ea575ad5ff5d7a3c0d7986b6890913f7
7
+ data.tar.gz: f81e88adfd45196bbe0180a67487d4e03fc2ab9b0b8abc7354fb3d39e49efa9e1f43eb6b6c86aa7b42b4c293826dee4a0a74f0482b2d1b287cf7b13f01e4d435
@@ -5,6 +5,8 @@ module Gitlab
5
5
  module Core
6
6
  # All the possible statuses emitted by the scan operation
7
7
  class Status
8
+ # These values must stay in-sync with the GRPC::ScanResponse::Status values
9
+ UNSPECIFIED = 0 # to match the GRPC::Status values
8
10
  FOUND = 1 # When scan operation completes with one or more findings
9
11
  FOUND_WITH_ERRORS = 2 # When scan operation completes with one or more findings along with some errors
10
12
  SCAN_TIMEOUT = 3 # When the scan operation runs beyond given time out
@@ -13,6 +15,38 @@ module Gitlab
13
15
  INPUT_ERROR = 6 # When the scan operation fails due to invalid input
14
16
  NOT_FOUND = 7 # When scan operation completes with zero findings
15
17
  AUTH_ERROR = 8 # When authentication fails
18
+
19
+ # Maps values to constants
20
+ @values_map = {}
21
+
22
+ # Using class instance variables and singleton methods
23
+ class << self
24
+ attr_reader :values_map
25
+
26
+ # Register constants and their values in the map
27
+ def const_set(name, value)
28
+ const = super
29
+ @values_map[value] = name
30
+ const
31
+ end
32
+
33
+ # Look up a constant by its value
34
+ def find_by_value(value)
35
+ const_name = @values_map[value]
36
+ const_name ? const_get(const_name) : nil
37
+ end
38
+
39
+ # Get the name of a constant by its value
40
+ def name_by_value(value)
41
+ @values_map[value]
42
+ end
43
+ end
44
+
45
+ # Initialize the values map with existing constants
46
+ constants.each do |const_name|
47
+ const_value = const_get(const_name)
48
+ @values_map[const_value] = const_name
49
+ end
16
50
  end
17
51
  end
18
52
  end
@@ -36,7 +36,7 @@ module Gitlab
36
36
  deadline: request_deadline
37
37
  )
38
38
 
39
- convert_to_core_response(grpc_response)
39
+ grpc_response
40
40
  end
41
41
  end
42
42
 
@@ -57,11 +57,10 @@ module Gitlab
57
57
  metadata: build_metadata(auth_token, extra_headers),
58
58
  deadline: request_deadline
59
59
  ).each do |grpc_response|
60
- response = convert_to_core_response(grpc_response)
61
60
  if block_given?
62
- yield response
61
+ yield grpc_response
63
62
  else
64
- results << response
63
+ results << grpc_response
65
64
  end
66
65
  end
67
66
  results
@@ -131,19 +130,6 @@ module Gitlab
131
130
  metadata: { message: e.details }
132
131
  )
133
132
  end
134
-
135
- def convert_to_core_response(grpc_response)
136
- response = grpc_response.to_h
137
-
138
- SecretDetection::Core::Response.new(
139
- status: response[:status],
140
- results: response[:results],
141
- metadata: response[:metadata]
142
- )
143
- rescue StandardError => e
144
- @logger.error("Failed to convert to core response: #{e}")
145
- SecretDetection::Core::Response.new(status: SecretDetection::Core::Status::SCAN_ERROR)
146
- end
147
133
  end
148
134
  end
149
135
  end
@@ -5,7 +5,7 @@
5
5
  require 'google/protobuf'
6
6
 
7
7
 
8
- descriptor_data = "\n\x16secret_detection.proto\x12\x17gitlab.secret_detection\"Z\n\tExclusion\x12>\n\x0e\x65xclusion_type\x18\x01 \x01(\x0e\x32&.gitlab.secret_detection.ExclusionType\x12\r\n\x05value\x18\x02 \x01(\t\"\xc0\x02\n\x0bScanRequest\x12>\n\x08payloads\x18\x01 \x03(\x0b\x32,.gitlab.secret_detection.ScanRequest.Payload\x12\x19\n\x0ctimeout_secs\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12!\n\x14payload_timeout_secs\x18\x03 \x01(\x02H\x01\x88\x01\x01\x12\x36\n\nexclusions\x18\x04 \x03(\x0b\x32\".gitlab.secret_detection.Exclusion\x12\x0c\n\x04tags\x18\x05 \x03(\t\x1a\x43\n\x07Payload\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\t\x12\x13\n\x06offset\x18\x03 \x01(\x05H\x00\x88\x01\x01\x42\t\n\x07_offsetB\x0f\n\r_timeout_secsB\x17\n\x15_payload_timeout_secs\"\xa2\x04\n\x0cScanResponse\x12>\n\x07results\x18\x01 \x03(\x0b\x32-.gitlab.secret_detection.ScanResponse.Finding\x12\x0e\n\x06status\x18\x02 \x01(\x05\x12>\n\x12\x61pplied_exclusions\x18\x03 \x03(\x0b\x32\".gitlab.secret_detection.Exclusion\x1a\x9d\x01\n\x07\x46inding\x12\x12\n\npayload_id\x18\x01 \x01(\t\x12\x0e\n\x06status\x18\x02 \x01(\x05\x12\x11\n\x04type\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x18\n\x0b\x64\x65scription\x18\x04 \x01(\tH\x01\x88\x01\x01\x12\x18\n\x0bline_number\x18\x05 \x01(\x05H\x02\x88\x01\x01\x42\x07\n\x05_typeB\x0e\n\x0c_descriptionB\x0e\n\x0c_line_number\"\xe1\x01\n\x06Status\x12\x16\n\x12STATUS_UNSPECIFIED\x10\x00\x12\x10\n\x0cSTATUS_FOUND\x10\x01\x12\x1c\n\x18STATUS_FOUND_WITH_ERRORS\x10\x02\x12\x17\n\x13STATUS_SCAN_TIMEOUT\x10\x03\x12\x1a\n\x16STATUS_PAYLOAD_TIMEOUT\x10\x04\x12\x15\n\x11STATUS_SCAN_ERROR\x10\x05\x12\x16\n\x12STATUS_INPUT_ERROR\x10\x06\x12\x14\n\x10STATUS_NOT_FOUND\x10\x07\x12\x15\n\x11STATUS_AUTH_ERROR\x10\x08*\x7f\n\rExclusionType\x12\x1e\n\x1a\x45XCLUSION_TYPE_UNSPECIFIED\x10\x00\x12\x17\n\x13\x45XCLUSION_TYPE_RULE\x10\x01\x12\x1c\n\x18\x45XCLUSION_TYPE_RAW_VALUE\x10\x02\x12\x17\n\x13\x45XCLUSION_TYPE_PATH\x10\x03\x32\xc1\x01\n\x07Scanner\x12U\n\x04Scan\x12$.gitlab.secret_detection.ScanRequest\x1a%.gitlab.secret_detection.ScanResponse\"\x00\x12_\n\nScanStream\x12$.gitlab.secret_detection.ScanRequest\x1a%.gitlab.secret_detection.ScanResponse\"\x00(\x01\x30\x01\x42 \xea\x02\x1dGitlab::SecretDetection::GRPCb\x06proto3"
8
+ descriptor_data = "\n\x16secret_detection.proto\x12\x17gitlab.secret_detection\"Z\n\tExclusion\x12>\n\x0e\x65xclusion_type\x18\x01 \x01(\x0e\x32&.gitlab.secret_detection.ExclusionType\x12\r\n\x05value\x18\x02 \x01(\t\"\xc0\x02\n\x0bScanRequest\x12>\n\x08payloads\x18\x01 \x03(\x0b\x32,.gitlab.secret_detection.ScanRequest.Payload\x12\x19\n\x0ctimeout_secs\x18\x02 \x01(\x02H\x00\x88\x01\x01\x12!\n\x14payload_timeout_secs\x18\x03 \x01(\x02H\x01\x88\x01\x01\x12\x36\n\nexclusions\x18\x04 \x03(\x0b\x32\".gitlab.secret_detection.Exclusion\x12\x0c\n\x04tags\x18\x05 \x03(\t\x1a\x43\n\x07Payload\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\t\x12\x13\n\x06offset\x18\x03 \x01(\x05H\x00\x88\x01\x01\x42\t\n\x07_offsetB\x0f\n\r_timeout_secsB\x17\n\x15_payload_timeout_secs\"\xa2\x04\n\x0cScanResponse\x12>\n\x07results\x18\x01 \x03(\x0b\x32-.gitlab.secret_detection.ScanResponse.Finding\x12\x0e\n\x06status\x18\x02 \x01(\x05\x12>\n\x12\x61pplied_exclusions\x18\x03 \x03(\x0b\x32\".gitlab.secret_detection.Exclusion\x1a\x9d\x01\n\x07\x46inding\x12\x12\n\npayload_id\x18\x01 \x01(\t\x12\x0e\n\x06status\x18\x02 \x01(\x05\x12\x11\n\x04type\x18\x03 \x01(\tH\x00\x88\x01\x01\x12\x18\n\x0b\x64\x65scription\x18\x04 \x01(\tH\x01\x88\x01\x01\x12\x18\n\x0bline_number\x18\x05 \x01(\x05H\x02\x88\x01\x01\x42\x07\n\x05_typeB\x0e\n\x0c_descriptionB\x0e\n\x0c_line_number\"\xe1\x01\n\x06Status\x12\x16\n\x12STATUS_UNSPECIFIED\x10\x00\x12\x10\n\x0cSTATUS_FOUND\x10\x01\x12\x1c\n\x18STATUS_FOUND_WITH_ERRORS\x10\x02\x12\x17\n\x13STATUS_SCAN_TIMEOUT\x10\x03\x12\x1a\n\x16STATUS_PAYLOAD_TIMEOUT\x10\x04\x12\x15\n\x11STATUS_SCAN_ERROR\x10\x05\x12\x16\n\x12STATUS_INPUT_ERROR\x10\x06\x12\x14\n\x10STATUS_NOT_FOUND\x10\x07\x12\x15\n\x11STATUS_AUTH_ERROR\x10\x08*\xa1\x01\n\rExclusionType\x12\x1e\n\x1a\x45XCLUSION_TYPE_UNSPECIFIED\x10\x00\x12\x17\n\x13\x45XCLUSION_TYPE_RULE\x10\x01\x12\x1c\n\x18\x45XCLUSION_TYPE_RAW_VALUE\x10\x02\x12\x17\n\x13\x45XCLUSION_TYPE_PATH\x10\x03\x12 \n\x1c\x45XCLUSION_TYPE_REGEX_PATTERN\x10\x04\x32\xc1\x01\n\x07Scanner\x12U\n\x04Scan\x12$.gitlab.secret_detection.ScanRequest\x1a%.gitlab.secret_detection.ScanResponse\"\x00\x12_\n\nScanStream\x12$.gitlab.secret_detection.ScanRequest\x1a%.gitlab.secret_detection.ScanResponse\"\x00(\x01\x30\x01\x42 \xea\x02\x1dGitlab::SecretDetection::GRPCb\x06proto3"
9
9
 
10
10
  pool = Google::Protobuf::DescriptorPool.generated_pool
11
11
  pool.add_serialized_file(descriptor_data)
@@ -8,7 +8,7 @@ module Gitlab
8
8
  # https://gitlab.com/gitlab-org/gitlab/-/issues/514015
9
9
  #
10
10
  # Ensure to maintain the same version in CHANGELOG file.
11
- VERSION = "0.20.0"
11
+ VERSION = "0.20.2"
12
12
 
13
13
  # SD_ENV env var is used to determine which environment the
14
14
  # server is running. This var is defined in `.runway/env-<env>.yml` files.
@@ -18,6 +18,7 @@ enum ExclusionType {
18
18
  EXCLUSION_TYPE_RULE = 1; // Rule ID to exclude
19
19
  EXCLUSION_TYPE_RAW_VALUE = 2; // Raw value to exclude
20
20
  EXCLUSION_TYPE_PATH = 3; // Specific file path to exclude
21
+ EXCLUSION_TYPE_REGEX_PATTERN = 4; // Regular expression to exclude
21
22
  }
22
23
 
23
24
  /* Request arg for triggering Scan/ScanStream method */
@@ -40,6 +41,7 @@ message ScanRequest {
40
41
  }
41
42
 
42
43
  /* Response from Scan/ScanStream method */
44
+ /* Any changes to these definitions must be matched by changes in the Core classes that correspond to them */
43
45
  message ScanResponse {
44
46
  // Represents a secret finding identified within a payload
45
47
  message Finding {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-secret_detection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.20.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - group::secret detection
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-02-25 00:00:00.000000000 Z
13
+ date: 2025-03-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: grpc