Skip to content

Commit

Permalink
Merge branch '10.0.3'
Browse files Browse the repository at this point in the history
Merging changes for BreakingPoint 10.0 Patch3 release
  • Loading branch information
nutu committed Nov 15, 2024
2 parents 2055897 + c069f1f commit 3a423a5
Show file tree
Hide file tree
Showing 16 changed files with 17,373 additions and 245 deletions.
3,690 changes: 3,631 additions & 59 deletions RestApi/Python/RestApi_v2/Modules/bps_restpy/restPyWrapper.py

Large diffs are not rendered by default.

3,690 changes: 3,631 additions & 59 deletions RestApi/Python/RestApi_v2/Modules/bps_restpy/restPyWrapper3.py

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import os
# Add bps_restpy libpath *required if the library is not installed
libpath = os.path.abspath(__file__+"/../../..")
libpath = os.path.abspath(__file__+"/../../")
sys.path.insert(0, libpath)
sys.path.insert(0,libpath)

import logging

from restPyWrapper3 import BPS, pp
from bps_restpy.bps import BPS, pp
from bpsVELicense import BPSVELicenseManagement
########################################

Expand All @@ -32,13 +32,9 @@
bps_system = '<BPS_BOX_IP/HOSTNAME>'
bpsuser = 'bps user'
bpspass = 'bps pass'
bps_system = '10.36.82.74'
bpsuser = 'admin'
bpspass = 'admin'

mainLicenseServer = '<License_Server_IP/HOSTNAME>'
mainLicenseServer = "10.36.66.31"
activationCode = '<Activation_Code>'
activationCode = ""
########################################


Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from collections import defaultdict

class DifferenceReport:

def __init__(self):
self.sections = [] # -> dict {Section ID, Section Name, Strike Total Difference, Detail Difference[Time of Strike, Strike Name, Strike Reference, Permutations, Strike Tuples]}
self.raw_sections = []
def add_change(self,section):
self.sections.append(section)

def add_raw_change(self,raw_section):
self.raw_sections.append(raw_section)

def print_all(self, security):
print("Differences:")
if security:
with open("checkResult.txt", "w") as file:
for section in self.sections:
if "Strike Total Difference" in section and "Detail Difference" in section:
section_id = section["Section ID"]
section_name = section["Section Name"]
file.write("Section ID: {0}\n".format(section_id))
file.write("Section Name: {0}\n".format(section_name))
print("Section ID: {0}".format(section_id))
print("Section Name: {0}".format(section_name))
file.write("Strike Total Difference: {0}\n".format(section["Strike Total Difference"]))
print("Strike Total Difference: {0}\n".format(section["Strike Total Difference"]))
for i in range(len(section["Detail Difference"]["Time of strike"])):
file.write("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i]))
file.write("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i]))
file.write("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i]))
file.write("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i]))
file.write("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i]))
file.write("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i]))
#print
print("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i]))
print("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i]))
print("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i]))
print("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i]))
print("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i]))
print("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i]))
print("++++++++++++++++++++++++++++++++++++")
file.write("++++++++++++++++++++++++++++++++++++\n")
file.write("===============================================================\n")
print("===============================================================")
else:
with open("checkResult.txt", "w") as file:
for section in self.sections:
section_id = section["Section ID"]
section_name = section["Section Name"]
file.write("Section ID: {0}\n".format(section_id))
file.write("Section Name: {0}\n".format(section_name))
print("Section ID: {0}".format(section_id))
print("Section Name: {0}".format(section_name))
if "Strike Total Difference" in section and "Detail Difference" in section:
file.write("Strike Total Difference: {0}\n".format(section["Strike Total Difference"]))
print("Strike Total Difference: {0}\n".format(section["Strike Total Difference"]))
for i in range(len(section["Detail Difference"]["Time of strike"])):
file.write("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i]))
file.write("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i]))
file.write("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i]))
file.write("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i]))
file.write("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i]))
file.write("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i]))
#print
print("Time of Strike: {0}\n".format(section["Detail Difference"]["Time of strike"][i]))
print("Strike Name: {0}\n".format(section["Detail Difference"]["Strike Name"][i]))
print("Strike Result: {0}\n".format(section["Detail Difference"]["Strike Result"][i]))
print("Strike Reference: {0}\n".format(section["Detail Difference"]["Strike Reference"][i]))
print("Permutations: {0}\n".format(section["Detail Difference"]["Permutations"][i]))
print("Strike Tuples: {0}\n".format(section["Detail Difference"]["Strike Tuples"][i]))
print("++++++++++++++++++++++++++++++++++++")
file.write("++++++++++++++++++++++++++++++++++++\n")
file.write("===============================================================\n")
print("===============================================================")

def print_raw_all(self):
print("Difference: ")
with open ("checkResult.txt", "a+") as file:
for raw_section in self.raw_sections:
print("Section ID: {0}".format(raw_section.id))
print("Section Name: {0}".format(raw_section.name))
file.write("Section ID: {0}\n".format(raw_section.id))
file.write("Section Name: {0}\n".format("Section Name: {0}".format(raw_section.name)))



Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import sys, os, re, time
from Section import Section
from collections import defaultdict
from DifferenceReport import DifferenceReport
sys.path.append(os.path.dirname(__file__))
from restPyWrapper3 import *

class ReportContent:

def __init__(self, bps, runId, security = False):
self.content = {}
self.bps = bps
self.sections = []
self.run_id = runId
self.security_check = security

def create_content(self):
self.content = self.bps.reports.getReportContents(runid=self.run_id, getTableOfContents=True)

def load_all_section(self):
id_of_security_start = ""
for i in range(len(self.content)):
id = self.content[i]["Section ID"]
name = self.content[i]["Section Name"]
section_split = id.split(".")
if len(section_split) > 1:
parent_id = ".".join(id.split(".")[:-1])
parent_section = self.retrieve_section_by_id(parent_id)
if parent_section:
parent_section.children.append(id)
section = Section(id,name,i)
if id_of_security_start:
if id.startswith(id_of_security_start):
section.security = True
section.load_section()
section.normalize_variant_name()
elif name == "Component Detection Assessment":
id_of_security_start = id
# Now all the security section children gets the detail of the table
self.sections.append(section)

def retrieve_section_by_id(self, section_id):
for section in self.sections:
if section_id == section.id:
return section
return None

def compare_reportContent(self, content_to_compare): #
try:
difference = DifferenceReport()
for section in self.sections:
section_to_compare = content_to_compare.find_diff_sections(section)
if section_to_compare: # Same Name Security or not Security

# Any difference in the exisiting list
if section.security and not section.children: # if it's a child
section.get_security_content(self.bps, self.run_id)
if not section_to_compare.children and not section_to_compare.detail:
difference.add_change(section.to_dict())
else:
if section.security_strike_total != section_to_compare.security_strike_total:
section_diff = section.compare_security(section_to_compare,self.sections)
difference.add_change(section_diff)
else:
difference.add_change(section.to_dict())
else:
if section.security and not section.children: # if it's a child
section.get_security_content(self.bps, self.run_id)
difference.add_change(section.to_dict())
difference.print_all(self.security_check)
except Exception as err:
raise Exception(str(err))


def compare_raw_reportContent(self, content_to_compare): #
try:
difference = DifferenceReport()
for section in self.sections:
if not content_to_compare.find_sections_by_name(section.name): # The name are totally different, new section found
# Any difference in the exisiting list
difference.add_raw_change(section) # if it's a security component, it will generate things from detail
difference.print_raw_all()
except Exception as err:
raise Exception(str(err))

def find_diff_sections(self, section_to_compare):
for section in self.sections:
if section.security and section_to_compare.security:
if section.relative_name == section_to_compare.relative_name:
return section
else:
if section.name == section_to_compare.name:
return section
return None


def find_sections_by_name(self, section_name):
for section in self.sections:
if section.name == section_name:
return True
return False
Loading

0 comments on commit 3a423a5

Please sign in to comment.