Added EXEC_SUMMARY switch

This commit is contained in:
skyanth 2016-11-28 17:53:38 +01:00
parent faee275e5e
commit 7b326fbba3
11 changed files with 250 additions and 90 deletions

View File

@ -167,11 +167,21 @@
<xs:attribute name="id" use="required" type="xs:ID"/>
<xs:attribute ref="break" use="optional"/>
<xs:attribute ref="visibility" use="optional"/>
<xs:attribute ref="inexecsummary" use="optional"/>
<xs:attribute ref="xml:base"/>
<xs:attribute ref="xml:lang"/>
</xs:complexType>
</xs:element>
<xs:attribute name="inexecsummary">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:element name="non-finding">
<xs:complexType>
<xs:sequence>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="conclusion" xml:base="conclusion.xml" break="before">
<section id="conclusion" xml:base="conclusion.xml" break="before" inexecsummary="yes">
<title>Conclusion</title>
</section>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="futurework" xml:base="futurework.xml" break="before">
<section id="futurework" xml:base="futurework.xml" break="before" inexecsummary="no">
<title>Future Work</title>
</section>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<section id="methodology" xml:base="methodology.xml" break="before">
<section id="methodology" xml:base="methodology.xml" break="before" inexecsummary="yes">
<title>Methodology</title>
<section id="planning">
<title>Planning</title>

View File

@ -29,6 +29,7 @@
<!-- ****** AUTO_NUMBERING_FORMAT: value of the <xsl:number> element used for auto numbering -->
<xsl:param name="AUTO_NUMBERING_FORMAT" select="'1.1.1'"/>
<xsl:param name="EXEC_SUMMARY" select="true()"/>
<xsl:key name="rosid" match="section|finding|appendix|non-finding" use="@id"/><xsl:key name="biblioid" match="biblioentry" use="@id"/>

View File

@ -20,7 +20,7 @@
DOCUMENT</fo:inline>
</xsl:when>
<xsl:when
test="starts-with(@href, '#') and //*[@id = $destination][ancestor-or-self::*[@visibility = 'hidden']]">
test="(starts-with(@href, '#') and //*[@id = $destination][ancestor-or-self::*[@visibility = 'hidden']]) or (starts-with(@href, '#') and $EXEC_SUMMARY=true() and //*[@id = $destination][ancestor-or-self::*[not(@inexecsummary='yes')]])">
<fo:inline xsl:use-attribute-sets="errortext">WARNING: LINK TARGET IS
HIDDEN</fo:inline>
</xsl:when>

View File

@ -19,7 +19,12 @@
<fo:external-graphic xsl:use-attribute-sets="logo"/>
</fo:block>
<fo:block xsl:use-attribute-sets="title-0">
<xsl:value-of select="upper-case(title)"/>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY=true()">
<xsl:text>PENETRATION TEST MANAGEMENT SUMMARY</xsl:text>
</xsl:when>
<xsl:otherwise><xsl:value-of select="upper-case(title)"/></xsl:otherwise>
</xsl:choose>
</fo:block>
<fo:block xsl:use-attribute-sets="for">
<xsl:text>for</xsl:text>
@ -90,7 +95,12 @@
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="td">
<fo:block>
<xsl:value-of select="title"/>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY=true()">
<xsl:text>PENETRATION TEST MANAGEMENT SUMMARY</xsl:text>
</xsl:when>
<xsl:otherwise><xsl:value-of select="upper-case(title)"/></xsl:otherwise>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>

View File

@ -1,54 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="2.0">
<xsl:template match="finding" mode="number">
<!-- Output finding display number (context is finding) -->
<xsl:variable name="sectionNumber">
<xsl:choose>
<xsl:when test="/pentest_report/@findingNumberingBase = 'Section'">
<xsl:value-of select="count(ancestor::section[last()]/preceding-sibling::section) + 1"/>
<xsl:value-of
select="count(ancestor::section[last()]/preceding-sibling::section) + 1"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="findingNumber" select="count(preceding::finding)+1"/>
<xsl:variable name="findingNumber" select="count(preceding::finding) + 1"/>
<xsl:variable name="numFormat" select="'00'"/>
<xsl:value-of
select="concat(ancestor::*[@findingCode][1]/@findingCode,'-',$sectionNumber, string(format-number($findingNumber, $numFormat)))"
select="concat(ancestor::*[@findingCode][1]/@findingCode, '-', $sectionNumber, string(format-number($findingNumber, $numFormat)))"
/>
</xsl:template>
<xsl:template match="section[not(@visibility='hidden')]|appendix[not(@visibility='hidden')]|non-finding" mode="number">
<xsl:template
match="section[not(@visibility = 'hidden')] | appendix[not(@visibility = 'hidden')] | non-finding"
mode="number">
<xsl:choose>
<xsl:when test="self::appendix">
<fo:inline> Appendix&#160;<xsl:number count="appendix[not(@visibility='hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::appendix">
<fo:inline> App&#160;<xsl:number count="appendix" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number count="section[ancestor::appendix][not(@visibility='hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:choose>
<xsl:when test="self::appendix">
<fo:inline> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::appendix">
<fo:inline> App&#160;<xsl:number count="appendix" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[ancestor::appendix][not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number
count="section[not(@visibility = 'hidden')][ancestor-or-self::*/@inexecsummary = 'yes'] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number count="section[not(@visibility='hidden')]|finding|non-finding" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:choose>
<xsl:when test="self::appendix">
<fo:inline> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::appendix">
<fo:inline> App&#160;<xsl:number count="appendix" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[ancestor::appendix][not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number
count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="biblioentry" mode="number">
<fo:inline>
<xsl:number count="biblioentry"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<fo:inline>
<xsl:number count="biblioentry" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>

View File

@ -76,7 +76,7 @@
<generate_index/>
<section id="executiveSummary">
<section id="executiveSummary" inexecsummary="yes">
<title>Executive Summary</title>
<section id="introduction">
<title>Introduction</title>
@ -116,7 +116,7 @@
<xsl:attribute name="href">snippets/report/methodology.xml</xsl:attribute>
</xsl:element>
<section id="recon">
<section id="recon" inexecsummary="no">
<title>Reconnaissance and Fingerprinting</title>
<p>Through automated scans we were able to gain the following information about the
software and infrastructure. Detailed scan output can be found in the sections
@ -142,7 +142,7 @@
</section>
</section>
<section id="techSummary">
<section id="techSummary" inexecsummary="no">
<title>Pentest Technical Summary</title>
<section id="findings">
<title>Findings</title>

View File

@ -1,20 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs" xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:template match="section|appendix|finding|non-finding|annex">
<xsl:if test="not(@visibility='hidden')">
<fo:block xsl:use-attribute-sets="section">
<xsl:if test="self::appendix or self::annex">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@*|node()"/>
</fo:block>
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="2.0">
<xsl:template match="section | appendix | finding | non-finding | annex">
<xsl:if test="not(@visibility = 'hidden')">
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:if test="ancestor-or-self::*/@inexecsummary = 'yes'">
<fo:block xsl:use-attribute-sets="section">
<xsl:if test="self::appendix or self::annex">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@* | node()"/>
</fo:block>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<fo:block xsl:use-attribute-sets="section">
<xsl:if test="self::appendix or self::annex">
<xsl:attribute name="break-before">page</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@* | node()"/>
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template match="title[not(parent::biblioentry)]">
<xsl:variable name="LEVEL" select="count(ancestor::*) - 1"/>
<xsl:variable name="CLASS">
@ -22,28 +35,61 @@
<xsl:text>title-</xsl:text>
<xsl:value-of select="$LEVEL"/>
</xsl:variable>
<fo:block>
<xsl:call-template name="use-att-set">
<xsl:with-param name="CLASS" select="$CLASS"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="self::title[parent::appendix]">
<fo:inline> Appendix&#160;<xsl:number count="appendix[not(@visibility='hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::appendix and not(self::title[parent::appendix])">
<fo:inline> App&#160;<xsl:number count="appendix[not(@visibility='hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number count="section[ancestor::appendix][not(@visibility='hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:choose>
<xsl:when test="self::title[parent::appendix]">
<fo:inline> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::appendix and not(self::title[parent::appendix])">
<fo:inline> App&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[ancestor::appendix][not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number
count="section[not(@visibility = 'hidden')][ancestor-or-self::*/@inexecsummary = 'yes'] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number count="section[not(@visibility='hidden')]|finding|non-finding" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:choose>
<xsl:when test="self::title[parent::appendix]">
<fo:inline> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:when test="ancestor::appendix and not(self::title[parent::appendix])">
<fo:inline> App&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[ancestor::appendix][not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number
count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#160;&#160;&#160;</xsl:text>
@ -58,5 +104,5 @@
<xsl:apply-templates select=".." mode="meta"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>

View File

@ -10,14 +10,32 @@
</fo:block>
</xsl:template>
<xsl:template match="meta | *[@visibility = 'hidden'] | *[../@visibilitiy = 'hidden']"
mode="toc"/>
<!-- meta, hidden things and children of hidden things not indexed -->
<xsl:template match="meta | *[ancestor-or-self::*/@visibility = 'hidden']" mode="toc"/>
<xsl:template match="*[ancestor-or-self::*/@inexecsummary = 'no']" mode="toc">
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()"/>
<xsl:otherwise>
<xsl:apply-templates mode="toc"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- meta, hidden things and children of hidden things not indexed; @inexecsummary="no" items are hidden only when a summary is requested -->
<xsl:template
match="section[not(@visibility = 'hidden')] | finding | appendix[not(@visibility = 'hidden')] | non-finding"
mode="toc">
<xsl:call-template name="ToC"/>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:if test="ancestor-or-self::*/@inexecsummary = 'yes'">
<xsl:call-template name="ToC"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="ToC"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ToC">
@ -26,7 +44,7 @@
<xsl:attribute name="internal-destination">
<xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:call-template name="tocContent"/>
<xsl:call-template name="tocContent"/>
</fo:basic-link>
<xsl:text> </xsl:text>
<fo:leader leader-pattern="dots" leader-alignment="reference-area"
@ -39,9 +57,18 @@
<fo:page-number-citation ref-id="{@id}"/>
</fo:basic-link>
</fo:block>
<xsl:apply-templates
select="section[not(@visibility = 'hidden')][not(../@visibility = 'hidden')] | finding[not(../@visibility = 'hidden')] | non-finding[not(../@visibility = 'hidden')]"
mode="toc"/>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:apply-templates
select="section[not(@visibility = 'hidden')][not(../@visibility = 'hidden')][ancestor-or-self::*/@inexecsummary = 'yes']"
mode="toc"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="section[not(@visibility = 'hidden')][not(../@visibility = 'hidden')] | finding[not(../@visibility = 'hidden')] | non-finding[not(../@visibility = 'hidden')]"
mode="toc"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="tocContent">
@ -67,22 +94,56 @@
<xsl:template name="tocContent_Numbering">
<xsl:choose>
<xsl:when test="self::appendix[not(@visibility = 'hidden')]">
<fo:inline> Appendix&#160;<xsl:number count="appendix[not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()">
<fo:inline> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/></fo:inline>
</xsl:when>
<xsl:otherwise>
<fo:inline> Appendix&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/></fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="ancestor::appendix[not(@visibility = 'hidden')]">
<fo:inline> App&#160;<xsl:number count="appendix[not(@visibility = 'hidden')]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[not(@visibility = 'hidden')][ancestor::appendix[not(@visibility = 'hidden')]]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:if test="ancestor::appendix[@inexecsummary = 'yes']">
<fo:inline> App&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')][@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[not(@visibility = 'hidden')][ancestor-or-self::*/@inexecsummary = 'yes'][ancestor::appendix[not(@visibility = 'hidden')]]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<fo:inline> App&#160;<xsl:number
count="appendix[not(@visibility = 'hidden')]" level="multiple"
format="{$AUTO_NUMBERING_FORMAT}"/>.<xsl:number
count="section[not(@visibility = 'hidden')][ancestor::appendix[not(@visibility = 'hidden')]]"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
<xsl:choose>
<xsl:when test="$EXEC_SUMMARY = true()">
<xsl:number
count="section[not(@visibility = 'hidden')][ancestor-or-self::*/@inexecsummary = 'yes']"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</xsl:when>
<xsl:otherwise>
<fo:inline>
<xsl:number
count="section[not(@visibility = 'hidden')] | finding | non-finding"
level="multiple" format="{$AUTO_NUMBERING_FORMAT}"/>
</fo:inline>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>