Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. entities = [#<Entity:0x0055f364d9cd78 @name="entity-B", @internal_asn_number=64514, @classification_id="B">,#<Entity:0x0055f364d89070 @name="entity-A", @internal_asn_number=64513, @classification_id="A">]
  2.  
  3. array_hashes = [{"rulename"=>"entity-B_source_fqdn_1", "if"=>{"source.fqdn"=>"mail.tec.dsr.entityB.com"}, "then"=>{"event_description.text"=>"B"}}, {"rulename"=>"entity-B_destination_fqdn_1", "if"=>{"destination.fqdn"=>"mail.tec.dsr.entity_B.com"}, "then"=>{"event_description.text"=>"B"}}, {"rulename"=>"entity-A_source_fqdn_1", "if"=>{"source.fqdn"=>"194-65-57-128.entityA.com"}, "then"=>{"event_description.text"=>"A"}}, {"rulename"=>"entity-A_destination_fqdn_1", "if"=>{"destination.fqdn"=>"194-65-57-128.entityA.com"}, "then"=>{"event_description.text"=>"A"}}]
  4.  
  5. path = "/home/mf370/Desktop/RubyProject/"
  6. file_name = "_url_fqdn.conf"
  7.  
  8. entities.each do |entity|
  9. File.open(path + entity.name + file_name, "w") do |f|
  10. array_hashes.each do |rule|
  11. if rule['rulename'].match(entity.name)
  12. f.write(JSON.pretty_generate([rule]))
  13. end
  14. end
  15. end
  16.  
  17. [
  18. {
  19. "rulename": "entity-A_source_fqdn_1",
  20. "if": {
  21. "source.fqdn": "194-65-57-128.entityA.com"
  22. },
  23. "then": {
  24. "event_description.text": "A"
  25. }
  26. }
  27. ][
  28. {
  29. "rulename": "entity-A_destination_fqdn_1",
  30. "if": {
  31. "destination.fqdn": "194-65-57-128.entityA.com"
  32. },
  33. "then": {
  34. "event_description.text": "A"
  35. }
  36. }
  37. ]
  38.  
  39. [
  40. {
  41. "rulename": "entity-A_source_fqdn_1",
  42. "if": {
  43. "source.fqdn": "194-65-57-128.entityA.com"
  44. },
  45. "then": {
  46. "event_description.text": "A"
  47. }
  48. },
  49. {
  50. "rulename": "entity-A_destination_fqdn_1",
  51. "if": {
  52. "destination.fqdn": "194-65-57-128.entityA.com"
  53. },
  54. "then": {
  55. "event_description.text": "A"
  56. }
  57. }
  58. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement