- Modified a number of things related to the attack analysis tools.

* removed <term> wrappers
  * added <const> wrappers
  * removed <role><term> construct, now <rolename>R</rolename>
    constructs.
  * added <variables> section.
  * variable substitutions are followed through in runs. Thus, only
    unbound variables occur in the semitrace.
  * added the untested claims back in, so that all events in a
    role/semitrace are now shown. Note that they can be disabled
    again by using the new '-H' switch.
This commit is contained in:
ccremers 2005-06-02 08:25:45 +00:00
parent f8bafdcd60
commit 01124e2104
4 changed files with 155 additions and 25 deletions

View File

@ -295,6 +295,20 @@ switcher (const int process, const System sys, int index)
} }
} }
if (detect ('H', "human-readable", 0))
{
if (!process)
{
helptext ("-H,--human-readable",
"try to make the output human-friendly (e.g. in XML)");
}
else
{
sys->switchHuman = true;
return index;
}
}
/* ================== /* ==================
* Modelchecker only * Modelchecker only
*/ */

View File

@ -76,6 +76,7 @@ systemInit ()
sys->switchClaims = 0; // default don't report on claims sys->switchClaims = 0; // default don't report on claims
sys->switchClaimToCheck = NULL; // default check all claims sys->switchClaimToCheck = NULL; // default check all claims
sys->switchXMLoutput = 0; // default no xml output sys->switchXMLoutput = 0; // default no xml output
sys->switchHuman = false; // not human friendly by default
sys->switchGoalSelectMethod = 3; // default goal selection method sys->switchGoalSelectMethod = 3; // default goal selection method
sys->traverse = 12; // default traversal method sys->traverse = 12; // default traversal method

View File

@ -144,6 +144,7 @@ struct system
int switchGoalSelectMethod; //!< Goal selection method for Arachne engine int switchGoalSelectMethod; //!< Goal selection method for Arachne engine
Term switchClaimToCheck; //!< Which claim should be checked? Term switchClaimToCheck; //!< Which claim should be checked?
int switchXMLoutput; //!< xml output int switchXMLoutput; //!< xml output
int switchHuman; //!< human readable
//! Latex output switch. //! Latex output switch.
/** /**

View File

@ -31,6 +31,7 @@ extern Term TERM_Function; // from termlist.c
*/ */
static int xmlindent; // indent level for xml elements in output static int xmlindent; // indent level for xml elements in output
static Term only_claim_label; // if NULL, show all claims in xml event lists. Otherwise, only this one. static Term only_claim_label; // if NULL, show all claims in xml event lists. Otherwise, only this one.
static int show_substitution_path; // is only set to true for variable printing, normally false.
/* /*
* Default external interface: init/done * Default external interface: init/done
@ -43,6 +44,7 @@ xmlOutInit (void)
printf ("<scyther>\n"); printf ("<scyther>\n");
xmlindent = 1; xmlindent = 1;
only_claim_label = NULL; only_claim_label = NULL;
show_substitution_path = false;
} }
//! Close up //! Close up
@ -96,10 +98,18 @@ xmlOutInteger (const char *tag, const int value)
//! Print a term in XML form (iteration inner) //! Print a term in XML form (iteration inner)
void void
xmlTermPrintInner (const Term term) xmlTermPrintInner (Term term)
{ {
if (term != NULL) if (term != NULL)
{ {
if (!show_substitution_path)
{
/* In a normal situation, variables are immediately substituted, and
* only the result is output.
*/
term = deVar (term);
}
if (realTermLeaf (term)) if (realTermLeaf (term))
{ {
// Variable? // Variable?
@ -129,7 +139,9 @@ xmlTermPrintInner (const Term term)
else else
{ {
// Constant // Constant
printf ("<const>");
termPrint (term); // Must be a normal termPrint termPrint (term); // Must be a normal termPrint
printf ("</const>");
} }
} }
else else
@ -170,12 +182,17 @@ xmlTermPrintInner (const Term term)
} }
//! Print a term in XML form (wrapper) //! Print a term in XML form (wrapper)
/**
* In the original setupt, a <term> wrapper was added. It is disabled for now.
* If this turns out to be the preferred situation, xmlTermPrintInner can be
* renamed to xmlTermPrint and all will be well.
*/
void void
xmlTermPrint (const Term term) xmlTermPrint (const Term term)
{ {
printf ("<term>"); // printf ("<term>");
xmlTermPrintInner (term); xmlTermPrintInner (term);
printf ("</term>"); // printf ("</term>");
} }
//! Print a termlist in XML form //! Print a termlist in XML form
@ -240,11 +257,98 @@ roleTermPrint (const Term t)
typebuffer = t->type; typebuffer = t->type;
t->type = GLOBAL; t->type = GLOBAL;
xmlTermPrint (t); termPrint (t);
t->type = typebuffer; t->type = typebuffer;
} }
} }
//! Print a role term with <rolename> tag and indenting etc.
void
xmlRoleTermPrint (const Term t)
{
xmlIndentPrint ();
printf ("<rolename>");
roleTermPrint (t);
printf ("</rolename>\n");
}
//! Show a single variable instantiation, depth one
void
xmlVariableDepthOne (const Term variable)
{
/*
* To print a variable, we would wish to see only the first substitution.
* Therefore, we temporarily undo any further substitutions, and reset
* them at the end.
*/
Term varsubst; // substitution shortcut
Term nextsubst; // temporary buffer
varsubst = variable->subst;
if (varsubst != NULL && realTermVariable (varsubst))
{
nextsubst = varsubst->subst;
varsubst->subst = NULL;
}
else
{
nextsubst = NULL;
}
// Print the actual term
xmlIndentPrint ();
xmlTermPrint (variable);
printf ("\n");
if (nextsubst != NULL)
{
varsubst->subst = nextsubst;
}
}
//! Show variable instantiations
/**
* Show the instantiations of all variables. Maybe we need to restrict this,
* and scan only for those variables that actually occur in the semitrace.
*/
void
xmlVariables (const System sys)
{
int prev_mode; // buffer for show mode
int run; // for loop
prev_mode = show_substitution_path;
show_substitution_path = true;
xmlPrint ("<variables>");
xmlindent++;
run = 0;
while (run < sys->maxruns)
{
if (sys->runs[run].protocol != INTRUDER)
{
Termlist varlist;
varlist = sys->runs[run].locals;
while (varlist != NULL)
{
if (realTermVariable (varlist->term))
{
// xmlVariableDepthOne (varlist->term);
xmlIndentPrint ();
xmlTermPrint (varlist->term);
printf ("\n");
}
varlist = varlist->next;
}
}
run++;
}
xmlindent--;
xmlPrint ("</variables>");
show_substitution_path = prev_mode;
}
//! Show inverses //! Show inverses
void void
xmlInverses (const System sys) xmlInverses (const System sys)
@ -305,28 +409,35 @@ isProtocolInvolved (const System sys, const Protocol p)
//! Determine whether to show an event //! Determine whether to show an event
int int
isEventInteresting (const Roledef rd) isEventInteresting (const System sys, const Roledef rd)
{ {
if (rd->type != CLAIM) if (sys->switchHuman)
{ {
return 1; if (rd->type != CLAIM)
}
else
{
// A claim
if (only_claim_label == NULL)
{ {
return 1; return 1;
} }
else else
{ {
if (isTermEqual (only_claim_label, rd->label)) // A claim
if (only_claim_label == NULL)
{ {
return 1; return 1;
} }
else
{
if (isTermEqual (only_claim_label, rd->label))
{
return 1;
}
}
} }
return 0;
}
else
{
return 1;
} }
return 0;
} }
//! Show a single event from a run //! Show a single event from a run
@ -340,7 +451,7 @@ isEventInteresting (const Roledef rd)
void void
xmlOutEvent (const System sys, Roledef rd, const int run, const int index) xmlOutEvent (const System sys, Roledef rd, const int run, const int index)
{ {
if (!isEventInteresting (rd)) if (!isEventInteresting (sys, rd))
{ {
return; return;
} }
@ -457,12 +568,16 @@ xmlOutEvent (const System sys, Roledef rd, const int run, const int index)
void void
xmlRoleEventlist (const System sys, Roledef rd, int index) xmlRoleEventlist (const System sys, Roledef rd, int index)
{ {
xmlPrint ("<eventlist>");
xmlindent++;
while (rd != NULL) while (rd != NULL)
{ {
xmlOutEvent (sys, rd, -1, index); xmlOutEvent (sys, rd, -1, index);
index++; index++;
rd = rd->next; rd = rd->next;
} }
xmlindent--;
xmlPrint ("</eventlist>");
} }
//! Show all protocol roles that are in the attack. //! Show all protocol roles that are in the attack.
@ -486,7 +601,7 @@ xmlInvolvedProtocolRoles (const System sys)
{ {
xmlPrint ("<role>"); xmlPrint ("<role>");
xmlindent++; xmlindent++;
xmlOutTerm ("name", r->nameterm); xmlRoleTermPrint (r->nameterm);
xmlRoleEventlist (sys, r->roledef, 0); xmlRoleEventlist (sys, r->roledef, 0);
xmlindent--; xmlindent--;
xmlPrint ("</role>"); xmlPrint ("</role>");
@ -530,8 +645,10 @@ xmlAgentsOfRunPrint (const System sys, const int run)
while (roles != NULL) while (roles != NULL)
{ {
xmlPrint ("<role>"); xmlPrint ("<role>");
xmlOutTerm ("name", roles->term); xmlindent++;
xmlRoleTermPrint (roles->term);
xmlOutTerm ("agent", deVar (agentOfRunRole (sys, run, roles->term))); xmlOutTerm ("agent", deVar (agentOfRunRole (sys, run, roles->term)));
xmlindent--;
xmlPrint ("</role>"); xmlPrint ("</role>");
roles = roles->next; roles = roles->next;
} }
@ -564,10 +681,7 @@ xmlRunInfo (const System sys, const int run)
* more generic. */ * more generic. */
oldagent = r->nameterm->subst; oldagent = r->nameterm->subst;
r->nameterm->subst = NULL; r->nameterm->subst = NULL;
xmlIndentPrint (); xmlRoleTermPrint (r->nameterm);
printf ("<role>");
roleTermPrint (r->nameterm);
printf ("</role>\n");
/* reinstate substitution */ /* reinstate substitution */
r->nameterm->subst = oldagent; r->nameterm->subst = oldagent;
if (oldagent != NULL) if (oldagent != NULL)
@ -643,6 +757,7 @@ xmlOutSemitrace (const System sys)
/* mention the broken claim */ /* mention the broken claim */
buffer_only_claim_label = only_claim_label; buffer_only_claim_label = only_claim_label;
only_claim_label = NULL;
if (sys->current_claim != NULL) if (sys->current_claim != NULL)
{ {
xmlPrint ("<broken>"); xmlPrint ("<broken>");
@ -653,12 +768,11 @@ xmlOutSemitrace (const System sys)
xmlPrint ("</broken>"); xmlPrint ("</broken>");
only_claim_label = sys->current_claim->label; only_claim_label = sys->current_claim->label;
} }
else
{
only_claim_label = NULL;
}
/* any global information about the system */ /* any global information about the system */
xmlOutSysInfo (sys); xmlOutSysInfo (sys);
/* instantiations of the variables */
xmlVariables (sys);
/* semitrace */ /* semitrace */
xmlPrint ("<semitrace>"); xmlPrint ("<semitrace>");
xmlindent++; xmlindent++;