Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lastOutput = instname
mse.append("self.traces = %s" % lastOutput)
# Get init from analysis
mse.append("def initAnalysis(self):", 1)
if self.attack:
mse.append('self.attack = %s()' % type(self.attack).__name__)
for s in self.attack.getStatements('init'):
mse.append(s.replace("self.", "self.attack.").replace("UserScript.", "self."))
else:
mse.append('pass')
# Get init from reporting
mse.append("def initReporting(self):", 1)
mse.append("# Configures the attack observers (usually a set of GUI widgets)")
if len(ResultsBase.registeredObjects)>0:
for k, v in ResultsBase.registeredObjects.iteritems():
if hasattr(v,"setTraceSource"):
mse.append("self.api.getResults(\"%s\").setTraceSource(self.traces)" % k)
if hasattr(v,"setAnalysisSource"):
mse.append("self.api.getResults(\"%s\").setAnalysisSource(self.attack)" % k)
else:
mse.append("pass")
# Do the attack
mse.append("def run(self):", 1)
mse.append("self.attack.processTraces()")
# Get other commands from attack module
if self.attack:
for k in self.attack._smartstatements:
if k == 'init' or k == 'go' or k == 'done':
def addSettingsDocks(self):
self.settingsGeneralDock = self.addSettings(self.api.params)
self.settingsResultsDock = self.addSettings(ResultsBase.getClassParameter())
self.settingsScopeDock = self.addSettings(self.api.scopeParam)
self.settingsTargetDock = self.addSettings(self.api.targetParam)
# self.settingsTraceDock = self.addSettings(self.api.traceParam)
self.settingsAuxDock = self.addSettings(self.api.auxParam)
# Load all ActiveTraceObservers
self.windowMenu.addSeparator()
for k, v in ResultsBase.getClasses().items():
if issubclass(v, ActiveTraceObserver):
ResultsBase.createNew(k)
self.tabifyDocks([self.settingsGeneralDock, self.settingsResultsDock, self.settingsScopeDock, self.settingsTargetDock,
# self.settingsTraceDock,
self.settingsAuxDock])
def __init__(self, traceSource=None, connectTracePlot=True, name=None):
PreprocessingBase.__init__(self, traceSource, name=name)
self._rtrace = None
self._debugReturnSad = False
self._wdStart = 0
self._wdEnd = 1
self._maxshift = 1
if connectTracePlot:
traceplot = ResultsBase.registeredObjects["Trace Output Plot"]
else:
traceplot = None
self.params.addChildren([
{'name':'Ref Trace', 'key':'reftrace', 'type':'int', 'get':self._getRefTrace, 'set':self._setRefTrace},
{'name':'Max Shift +/-', 'key':'maxshift', 'type':'int', 'get':self._getMaxShift, 'set':self._setMaxShift},
{'name':'Target Window', 'key':'windowpt', 'type':'rangegraph', 'graphwidget':traceplot, 'get':self._getWindow, 'set':self._setWindow},
])
self.updateLimits()
self.sigTracesChanged.connect(self.updateLimits)
self._init_not_done = True
def addSettingsDocks(self):
self.settingsGeneralDock = self.addSettings(self.api.params)
self.settingsResultsDock = self.addSettings(ResultsBase.getClassParameter())
self.settingsScopeDock = self.addSettings(self.api.scopeParam)
self.settingsTargetDock = self.addSettings(self.api.targetParam)
# self.settingsTraceDock = self.addSettings(self.api.traceParam)
self.settingsAuxDock = self.addSettings(self.api.auxParam)
# Load all ActiveTraceObservers
self.windowMenu.addSeparator()
for k, v in ResultsBase.getClasses().items():
if issubclass(v, ActiveTraceObserver):
ResultsBase.createNew(k)
self.tabifyDocks([self.settingsGeneralDock, self.settingsResultsDock, self.settingsScopeDock, self.settingsTargetDock,
# self.settingsTraceDock,
self.settingsAuxDock])
def __init__(self, traceSource=None, name=None):
PreprocessingBase.__init__(self, traceSource, name=name)
self._rtrace = 0
self._debugReturnCorr = False
self._ccStart = 0
self._ccEnd = 0
self.params.addChildren([
{'name':'Ref Trace', 'key':'reftrace', 'type':'int', 'get':self._getRefTrace, 'set':self._setRefTrace},
{'name':'Window', 'key':'rwindow', 'type':'rangegraph', 'graphwidget':ResultsBase.registeredObjects["Trace Output Plot"], 'get':self._getWindow, 'set':self._setWindow},
# {'name':'Output Correlation (DEBUG)', 'type':'bool', 'value':False, 'set':self.setOutputCorr}
])
self._calculateRef()
def addSettingsDocks(self):
self.settingsGeneralDock = self.addSettings(self.api.params)
self.settingsResultsDock = self.addSettings(ResultsBase.getClassParameter())
self.settingsScopeDock = self.addSettings(self.api.scopeParam)
self.settingsTargetDock = self.addSettings(self.api.targetParam)
# self.settingsTraceDock = self.addSettings(self.api.traceParam)
self.settingsAuxDock = self.addSettings(self.api.auxParam)
# Load all ActiveTraceObservers
self.windowMenu.addSeparator()
for k, v in ResultsBase.getClasses().iteritems():
if issubclass(v, ActiveTraceObserver):
ResultsBase.createNew(k)
self.tabifyDocks([self.settingsGeneralDock, self.settingsResultsDock, self.settingsScopeDock, self.settingsTargetDock,
# self.settingsTraceDock,
self.settingsAuxDock])
def openPlotWidget(self, _):
if "Glitch Explorer" not in ResultsBase.registeredObjects:
ResultsBase.createNew("Scatter Plot", "Glitch Explorer")
widget = ResultsBase.registeredObjects["Glitch Explorer"]
widget.raise_()
widget.yLocked(False)
self.clearPlotWidget()
def connectScope(self):
"""Connect to the selected scope"""
try:
if self.getScope():
self.getScope().con()
try:
# Sets the Plot Widget input (if it exists) to the last added TraceSource
ResultsBase.registeredObjects["Trace Output Plot"].setTraceSource(
TraceSource.registeredObjects[next(reversed(TraceSource.registeredObjects))])
except KeyError:
pass
except Warning:
sys.excepthook(*sys.exc_info())
return False
return True
def __init__(self, traceSource=None, name=None):
PreprocessingBase.__init__(self, traceSource, name=name)
self._rtrace = 0
self._ccStart = 0
self._ccEnd = 0
self._limit = 0
self._type = "max"
self.params.addChildren([
{'name':'Ref Trace', 'key':'reftrace', 'type':'int', 'get':self._getRefTrace, 'set':self._setRefTrace},
{'name':'Peak Type', 'key':'peaktype', 'type':'list', 'values':['max', 'min'], 'get':self._getType, 'set':self._setType},
{'name':'Point Range', 'key':'ptrange', 'type':'rangegraph', 'graphwidget':ResultsBase.registeredObjects["Trace Output Plot"], 'get':self._getWindow, 'set':self._setWindow},
{'name':'Valid Limit', 'key':'vlimit', 'type':'float', 'step':0.1, 'limits':(0, 10), 'set':self._setLimit, 'get':self._getLimit},
])
self._calculateRef()
def clearPlotWidget(self):
widget = ResultsBase.registeredObjects.get("Glitch Explorer", None)
if widget is not None:
widget.clearPushed()
widget.setLabels(top="Glitch Map", xaxis=list(self.tune_parameter_list.keys())[0] if len(self.tune_parameter_list)>0 else "",
yaxis=list(self.tune_parameter_list.keys())[1] if len(self.tune_parameter_list)>1 else "")