Module: Pipeline::Util
- Included in:
- Brakeman, BundleAudit, Checkmarx, DawnScanner, ESLint, FindSecurityBugs, NodeSecurityProject, OWASPDependencyCheck, PMD, RetireJS, SFL, Test, Zap
- Defined in:
- lib/pipeline/util.rb
Instance Method Summary collapse
- #fingerprint(text) ⇒ Object
- #relative_path(path, pwd) ⇒ Object
- #runsystem(report, *splat) ⇒ Object
- #strip_archive_path(path, delimeter) ⇒ Object
Instance Method Details
#fingerprint(text) ⇒ Object
26 27 28 |
# File 'lib/pipeline/util.rb', line 26 def fingerprint text Digest::SHA2.new(256).update(text).to_s end |
#relative_path(path, pwd) ⇒ Object
34 35 36 37 38 |
# File 'lib/pipeline/util.rb', line 34 def relative_path path, pwd pathname = Pathname.new(path) return path if pathname.relative? pathname.relative_path_from(Pathname.new pwd) end |
#runsystem(report, *splat) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pipeline/util.rb', line 7 def runsystem(report,*splat) Open3.popen3(*splat) do |stdin, stdout, stderr, wait_thr| #puts *splat pid = wait_thr.pid res = stdout.read error = stderr.read exit = wait_thr.value if wait_thr.value != 0 && report # Weird. wait_thr value is non-0 for bundler-audit # but not brakeman. Comment to keep output cleaner... # puts res puts error #puts *splat end return res end end |
#strip_archive_path(path, delimeter) ⇒ Object
30 31 32 |
# File 'lib/pipeline/util.rb', line 30 def strip_archive_path path, delimeter path.split(delimeter).last.split('/')[1..-1].join('/') end |