72. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/20/2018 12:56:46 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

72.1 Files compared

# Location File Last Modified
1 CTT_Release_8_June_2018.zip\CTT_rails_common\util helpers.rb Tue Jul 17 16:27:23 2018 UTC
2 CTT_Release_8_June_2018.zip\CTT_rails_common\util helpers.rb Wed Jul 18 21:01:15 2018 UTC

72.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 428
Changed 1 2
Inserted 0 0
Removed 0 0

72.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

72.4 Active regular expressions

No regular expressions were active.

72.5 Comparison detail

  1   =begin
  2   Copyright  Notice
  3  
  4    This is a  work of t he U.S. Go vernment a nd is not  subject to  copyright
  5    protectio n in the U nited Stat es. Foreig n copyrigh ts may app ly.
  6  
  7    Licensed  under the  Apache Lic ense, Vers ion 2.0 (t he "Licens e");
  8    you may n ot use thi s file exc ept in com pliance wi th the Lic ense.
  9    You may o btain a co py of the  License at
  10  
  11    http://ww w.apache.o rg/license s/LICENSE- 2.0
  12  
  13    Unless re quired by  applicable  law or ag reed to in  writing,  software
  14    distribut ed under t he License  is distri buted on a n "AS IS"  BASIS,
  15    WITHOUT W ARRANTIES  OR CONDITI ONS OF ANY  KIND, eit her expres s or impli ed.
  16    See the L icense for  the speci fic langua ge governi ng permiss ions and
  17    limitatio ns under t he License .
  18   =end
  19   require 'u ri'
  20   module KOM ETUtilitie s
  21     TMP_FILE _PREFIX =  './tmp/'
  22     YML_EXT  = '.yml'
  23     MAVEN_TA RGET_DIREC TORY = './ target'
  24     ##
  25     # this m ethod take s a camel  cased word  and chang es it to s nake case
  26     # Exampl e: RailsKo met -> rai ls_komet
  27     #
  28     def to_s nake_case( camel_case d_word)
  29       camel_ cased_word .to_s.gsub (/::/, '/' ).
  30           gs ub(/([A-Z] +)([A-Z][a -z])/, '\1 _\2').
  31           gs ub(/([a-z\ d])([A-Z]) /, '\1_\2' ).
  32           tr ('-', '_') .
  33           do wncase
  34     end
  35  
  36     def self .isaac_res t_site_up? (uri:)
  37       result  = false
  38       begin
  39         path  = uri.pat h.empty? ?  '/' : uri .path
  40         path  << 'rest/ 1/system/s ystemInfo'
  41         resu lt = Net:: HTTP.new(u ri.host, u ri.port)
  42         resu lt.use_ssl  = uri.sch eme.eql?(' https')
  43         resu lt = (resu lt.head(pa th).kind_o f?(Net::HT TPSuccess)  || result .head(path ).kind_of? (Net::HTTP InternalSe rverError) )
  44           #  Net::HTTP. new(u, p). head('/'). kind_of? N et::HTTPOK
  45       rescue  => ex
  46         $log .warn("I c ould not c heck the U RL #{uri.p ath} at po rt #{uri.p ort} again st path #{ uri.path}  because #{ ex}.")
  47         resu lt = false
  48       end
  49       result
  50     end
  51  
  52     ##
  53     # writes  the json  data to a  tmp file b ased on th e filename  passed
  54     # @param  json - th e JSON dat a to write  out
  55     # @param  file_name  - the fil ename to w rite out t o the /tmp  directory
  56     def json _to_yaml_f ile(json,  file_name)
  57       if Rai ls.env.dev elopment?
  58         pref ix = '#Fix ture creat ed on ' +  Time.now.s trftime('% F %H:%M:%S ') + "\n"
  59         File .write("#{ TMP_FILE_P REFIX}#{fi le_name}"  + YML_EXT,  prefix +  json.to_ya ml)
  60         $log .trace("Wr iting yaml  file #{TM P_FILE_PRE FIX}#{file _name}.yml .")
  61       else
  62         $log .trace("No t writing  yaml file  #{TMP_FILE _PREFIX}#{ file_name} .yml. Rail s.env = #{ Rails.env} ")
  63       end
  64  
  65     end
  66  
  67     ##
  68     # Conver t the URL  to a strin g for use  with the j son_to_yam l_file met hod call
  69     # @param  url - the  URL path  to convert  to a stri ng with un derscores
  70     # @retur n - the fi lename bas ed on the  URL passed
  71     def url_ to_path_st ring(url)
  72       url =  url.clone
  73       begin
  74         url. gsub!('{',  '') #redu ce paths l ike http:/ /www.googl e.com/foo/ {id}/faa t o http://w ww.google. com/foo/id /faa
  75         url. gsub!('}',  '') #redu ce paths l ike http:/ /www.googl e.com/foo/ {id}/faa t o http://w ww.google. com/foo/id /faa
  76         path  = URI(url ).path.gsu b('/', '_' )
  77         path  = 'no_pat h' if path .empty?
  78         retu rn path
  79       rescue  => ex
  80         $log .error('An  invalid m atched_url  was given !')
  81         $log .error(ex)
  82       end
  83       'bad_u rl'
  84     end
  85  
  86     ##
  87     # Find a ll IDs in  a string a nd return  the match  object (ri ght now on ly UUID an d NID are  implemente d)
  88     # @param  [String]  string - t he string  to search  for UUIDs
  89     # @param  [String]  type - opt ional para mter to sp ecify whic h type of  ID to sear ch for. Va lues are [ uuid, nid]
  90     # @retur n - the ma tch object  from the  search
  91     def find _ids(strin g, type =  nil)
  92  
  93       expres sions = []
  94  
  95       if typ e == nil | | type ==  'uuid'
  96         expr essions <<  /[a-zA-Z0 -9]{8}-([a -zA-Z0-9]{ 4}-){3}[a- zA-Z0-9]{1 2}/
  97       end
  98  
  99       if typ e == nil | | type ==  'nid'
  100         expr essions <<  /-[0-9]{1 0}/
  101       end
  102  
  103       Regexp .union(exp ressions). match(stri ng.to_s)
  104     end
  105  
  106   end
  107  
  108   module Ker nel
  109     TRUE_VAL S = %w(tru e t yes y  on 1)
  110     FALSE_VA LS = %w(fa lse f no n  off 0)
  111  
  112     def bool ean(boolea n_string)
  113       val =  boolean_st ring.to_s. downcase.g sub(/\s+/,  '')
  114       return  false if  val.empty?
  115       return  true if T RUE_VALS.i nclude?(va l)
  116       return  false if  FALSE_VALS .include?( val)
  117       raise  ArgumentEr ror.new("i nvalid val ue for Boo lean: \"#{ val}\"")
  118     end
  119  
  120     def gov
  121       Java:: Gov
  122     end
  123  
  124   end
  125  
  126   module URI
  127     class <<  self
  128       # attr _accessor  :instance_ variable
  129     end
  130  
  131     def self .valid_url ?(url_stri ng:)
  132       ret =  true
  133       begin
  134         $log .debug("va lidating m atched_url  #{url_str ing}")
  135         u =  URI(url_st ring)
  136         unle ss %w(http  https).in clude?(u.s cheme)
  137           ra ise 'Bad U RI - retur ned Generi c or no ht tp or http s scheme f ound!'
  138         end
  139         $log .debug('va lid!')
  140       rescue  => ex
  141         $log .error("Th e matched_ url #{url_ string} is  malformed  in the pr oxy file." )
  142         $log .error("#{ ex.message }")
  143         ret  = false
  144       end
  145       ret
  146     end
  147  
  148     def base _url(inclu de_port =  true, trai ling_slash  = false)
  149       base_p ath = "#{s cheme}://# {host}"
  150       base_p ath << ":# {port}" if  include_p ort
  151       base_p ath << '/'  if traili ng_slash
  152       base_p ath
  153     end
  154  
  155       def to_htt ps(https_p ort =  PORT , trailing _slash = f alse)
  156       base_p ath = "htt ps://#{hos t}"
  157       base_p ath << ":# {https_por t}"
  158       base_p ath << '/'  if traili ng_slash
  159       base_p ath
  160     end
  161  
  162     def eql_ ignore_tra iling_slas h?(other)
  163       myself  = to_s
  164       other  = other.to _s
  165       myself  = myself. chop if (m yself[-1]. eql?('/'))
  166       other  = other.ch op if (oth er[-1].eql ?('/'))
  167       myself .eql? othe r
  168     end
  169   end
  170  
  171   #methods v isible in  Komet and  Prisme go  here.
  172   module Pri smeUtiliti es
  173     APPLICAT ION_URLS =  'applicat ion_urls'
  174     SSOI_LOG OUT = 'sso i_logout'
  175  
  176  
  177     def self .ssoi_logo ut_path_fr om_json_st ring(confi g_hash:)
  178       config _hash[APPL ICATION_UR LS][SSOI_L OGOUT]
  179     end
  180   end
  181  
  182   module Far adayUtilit ies
  183  
  184     CONNECTI ON_JSON =  Faraday.ne w do |fara day|
  185       farada y.request  :url_encod ed # form- encode POS T params
  186       farada y.use Fara day::Respo nse::Logge r, $log
  187       farada y.headers[ 'Accept']  = 'applica tion/json'
  188       farada y.adapter  :net_http  # make req uests with  Net::HTTP
  189     end
  190  
  191   end
  192  
  193   class Stri ng
  194     # simila r to the c amelize in  rails, bu t it only  mutates th e first ch aracter af ter the un derscore
  195     # Suppos e you have  the java  method 'ge tInterface EngineURL' , note how  the last  set of cha racters ar e all uppe rcase
  196     # "inter face_engin e_URL".cam elize() =>  "Interfac eEngineUrl "
  197     # "inter face_engin e_URL".cam elize_pres erving =>  "Interface EngineURL"
  198     # "inter face_engin e_URL".cam elize_pres erving(fal se) => "in terfaceEng ineURL"
  199     def came lize_prese rving(modi fy_first_l etter = tr ue)
  200       return  self.spli t('_').eac h_with_ind ex.collect  do |e, i|
  201         if ( (i == 0) & & !modify_ first_lett er)
  202         else
  203           e[ 0] = e[0]. capitalize
  204         end
  205         e
  206       end.jo in
  207     end
  208   end
  209  
  210   #
  211   module Jav aImmutable
  212     def meth od_missing (method_sy m, *args)
  213       raise  java.lang. Unsupporte dOperation Exception. new("This  class is i mmutable!" ) if metho d_sym.to_s  =~ /^set/
  214     end
  215   end