Introduced "all attacks" switch in GUI, and a bugfix.

Passing the '--all-attacks' switch to the backend was not working. The reason
was the hack to get Vista working hardcoded cutting to the last attack found.

In the long term, this needs to be cleaned up, and cutting should be moved back
nicely to the Scyther C code where it used to work. Once done, switches.useAttackBuffer
can be set back to true.

BUGFIX: When cutting attacks/patterns, counts are no longer exact.
This commit is contained in:
Cas Cremers 2008-07-30 00:03:46 +02:00
parent a0a377a84f
commit 9605d5e772
2 changed files with 33 additions and 8 deletions

View File

@ -71,14 +71,23 @@ class ScytherThread(threading.Thread):
wx.CallAfter(self.callback, scyther, claims, summary)
def claimFixViewOne(self,claims):
if claims:
for cl in claims:
if len(cl.attacks) > 1:
# Fix it such that by default, only the best attack is
# shown, unless we are in characterize or check mode
# TODO [X] [CC] make switch-dependant.
if not self.mode in ["characterize","check"]:
cl.attacks = [cl.attacks[-1]]
"""
This is a stupid hack as long as switches.useAttackBuffer in
Scyther C code is false. It is currently false because Windows
VISTA screwed up the standard C function tmpfile() (It's in a
directory to which normal users cannot write...)
"""
if int(Preference.get('allattacks','0')) == 0:
if claims:
for cl in claims:
if len(cl.attacks) > 1:
# Fix it such that by default, only the best attack is
# shown, unless we are in characterize or check mode
# TODO [X] [CC] make switch-dependant.
if not self.mode in ["characterize","check"]:
cl.attacks = [cl.attacks[-1]]
""" Cutting invalidates exactness of attack/behaviour counts """
cl.complete = False
return claims

View File

@ -98,6 +98,15 @@ class SettingsWindow(wx.Panel):
### MISC expert stuff
grid.titleAdd("Advanced parameters")
# Continue after finding the first attack
self.allattacks = int(Preference.get('allattacks','0'))
claimoptions = ['Yes','No']
r8 = wx.StaticText(self,-1,"Stop after finding one attack")
l8 = self.ch = wx.Choice(self,-1,choices=claimoptions)
l8.SetSelection(self.allattacks)
self.Bind(wx.EVT_CHOICE,self.EvtAllAttacks,l8)
grid.stepAdd(l8,r8)
# Bound on the number of patterns
self.maxattacks = int(Preference.get('maxattacks','10'))
r9 = wx.StaticText(self,-1,"Maximum number of patterns\nper claim")
@ -143,6 +152,10 @@ class SettingsWindow(wx.Panel):
def EvtFontsize(self,evt):
self.fontsize = evt.GetInt()
def EvtAllAttacks(self,evt):
self.allattacks = evt.GetInt()
Preference.set('allattacks',self.allattacks)
def EvtMaxAttacks(self,evt):
self.maxattacks = evt.GetInt()
@ -160,6 +173,9 @@ class SettingsWindow(wx.Panel):
tstr += "--max-runs=%s " % (str(self.maxruns))
# Matching type
tstr += "--match=%s " % (str(self.match))
# All attacks (has to go BEFORE max attacks)
if self.allattacks != 0:
tstr += "--all-attacks "
# Max attacks/classes
if self.maxattacks != 0:
tstr += "--max-attacks=%s " % (str(self.maxattacks))