Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/reports/security/locations/base.rb')
-rw-r--r--lib/gitlab/ci/reports/security/locations/base.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/gitlab/ci/reports/security/locations/base.rb b/lib/gitlab/ci/reports/security/locations/base.rb
new file mode 100644
index 00000000000..9ad1d81287f
--- /dev/null
+++ b/lib/gitlab/ci/reports/security/locations/base.rb
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Ci
+ module Reports
+ module Security
+ module Locations
+ class Base
+ include ::Gitlab::Utils::StrongMemoize
+
+ def ==(other)
+ other.fingerprint == fingerprint
+ end
+
+ def fingerprint
+ strong_memoize(:fingerprint) do
+ Digest::SHA1.hexdigest(fingerprint_data)
+ end
+ end
+
+ def as_json(options = nil)
+ fingerprint # side-effect call to initialize the ivar for serialization
+
+ super
+ end
+
+ def fingerprint_path
+ fingerprint_data
+ end
+
+ private
+
+ def fingerprint_data
+ raise NotImplementedError
+ end
+ end
+ end
+ end
+ end
+ end
+end