From 53836b0db44a04904f4dac6fc9f54bf87a74be53 Mon Sep 17 00:00:00 2001 From: Frank Xu Date: Fri, 15 Sep 2023 21:49:41 -0400 Subject: [PATCH] imporve readability NIST_data_leakage_01_registry.ppt --- .../bookstore_list_book_category_attrib.py | 2 +- .../bookstore_update_price_plus1.py | 2 +- .../bookstore_updated_price.xml | 20 +++++++++++++++++++ .../securityevt_show_first_event.py | 11 ++-------- 4 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_updated_price.xml diff --git a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_list_book_category_attrib.py b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_list_book_category_attrib.py index 36e0a1f..65d0c1f 100644 --- a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_list_book_category_attrib.py +++ b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_list_book_category_attrib.py @@ -1,6 +1,6 @@ import xml.etree.ElementTree as ET -tree = ET.parse("bookstore_removed_ns.xml") +tree = ET.parse("bookstore.xml") root = tree.getroot() # Iterate through the book elements and print their category attributes diff --git a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_update_price_plus1.py b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_update_price_plus1.py index f3f381d..0105a4d 100644 --- a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_update_price_plus1.py +++ b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_update_price_plus1.py @@ -13,5 +13,5 @@ for price_element in root.findall(".//price"): updated_xml_content = ET.tostring(root, encoding="utf-8") # Save the updated XML to a new file -with open("bookstore_updated.xml", "wb") as f: +with open("bookstore_updated_price.xml", "wb") as f: f.write(updated_xml_content) diff --git a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_updated_price.xml b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_updated_price.xml new file mode 100644 index 0000000..9fb6191 --- /dev/null +++ b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/bookstore_updated_price.xml @@ -0,0 +1,20 @@ + + + Everyday Italian + Giada De Laurentiis + 2005 + 31.0 + + + Harry Potter + J K. Rowling + 2005 + 30.99 + + + Learning XML + Erik T. Ray + 2003 + 40.95 + + \ No newline at end of file diff --git a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/securityevt_show_first_event.py b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/securityevt_show_first_event.py index 9dc05c0..cae3287 100644 --- a/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/securityevt_show_first_event.py +++ b/NIST_Data_Leakage_Case/py_version/pycode/security_evt_xml/securityevt_show_first_event.py @@ -1,7 +1,6 @@ import xml.etree.ElementTree as ET -import xml.dom.minidom as minidom -tree = ET.parse("SecurityEvt_ns_removed.xml") +tree = ET.parse("securityEvt_formatted.xml") root = tree.getroot() # Find the first Event element @@ -12,13 +11,7 @@ if first_event is not None: # Convert the first Event element to a string with pretty formatting first_event_str = ET.tostring(first_event, encoding="unicode", method="xml") - # Parse the XML content - dom = minidom.parseString(first_event_str) - - # Pretty print the XML content - pretty_xml = dom.toprettyxml(indent=" ") - # Print the nicely formatted XML - print(pretty_xml) + print(first_event_str) else: print("No Event elements found in the XML.")