MCPcopy Create free account
hub / github.com/secdev/scapy / new

Method new

scapy/modules/ldaphero.py:1815–1872  ·  view source on GitHub ↗

New popup. Called by both 'Add child' and 'Duplicate' popups

(self, mode)

Source from the content-addressed store, hash-verified

1813 self.tprint("OK !")
1814
1815 def new(self, mode):
1816 """
1817 New popup. Called by both 'Add child' and 'Duplicate' popups
1818 """
1819 if mode == "duplicate":
1820 # Get selected item
1821 try:
1822 selection = self.tk_tree.selection()[0]
1823 except IndexError:
1824 selection = ""
1825 else:
1826 selection = ""
1827
1828 existing_attributes = {}
1829 if selection:
1830 # Perform search to retrieve the attributes
1831 self.tprint("Getting attributes for %s..." % selection, flush=True)
1832 try:
1833 results = self.client.search(
1834 baseObject=selection,
1835 scope=0,
1836 )
1837 if selection not in results:
1838 raise ValueError("Bad result")
1839 existing_attributes = results[selection]
1840 except ValueError as ex:
1841 self.tprint(str(ex))
1842 return
1843 except LDAP_Exception as ex:
1844 self.tprint(
1845 ex.diagnosticMessage or "Error: %s" % ex.resultCode,
1846 tags=["error"],
1847 )
1848 return
1849
1850 # Show edit popup to be able to change an attribute
1851 results = self._edit_popup(selection, mode="new", editattrs=existing_attributes)
1852 if not results:
1853 return
1854 newdn, changes = results
1855
1856 # Extract all the 'add' attributes operations from changes
1857 attributes = {attr: val for (_, attr, val) in changes}
1858
1859 self.tprint("Adding %s..." % newdn)
1860 try:
1861 self.client.add(
1862 newdn,
1863 attributes=attributes,
1864 )
1865 except LDAP_Exception as ex:
1866 self.tprint(
1867 ex.diagnosticMessage or "Error: %s" % ex.resultCode,
1868 tags=["error"],
1869 )
1870 return
1871
1872 self.tprint("OK !")

Callers 9

duplicateMethod · 0.95
addchildMethod · 0.95
build_hmac_sha1Method · 0.80
_hmac_sha1_digestFunction · 0.80
send_wpa_handshake_3Method · 0.80
customPRF512Function · 0.80
digestMethod · 0.80

Calls 4

tprintMethod · 0.95
_edit_popupMethod · 0.95
searchMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected