Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump actions/checkout from 3.3.0 to 3.5.3 #333

Open
wants to merge 139 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
25505c2
Release 1.0 metaschema adjustments (#1065)
david-waltermire Dec 9, 2021
929005a
reverting part constraints, since these are already handled
david-waltermire Jan 31, 2022
63def77
Profile resolver selection: XSpec additions and minor XSLT enhancemen…
galtm Feb 4, 2022
dd09086
Use XSpec variable instead of entity (#1136)
galtm Feb 28, 2022
9d0cbb3
Nonrecursive UUID functions plus XSpec tests (#1158)
galtm Feb 28, 2022
79db795
Iterate over sequence of characters, not positions (#1163)
galtm Mar 29, 2022
3e16c9d
Profile resolver: Metadata tests and way of determining top UUID (#1175)
galtm Apr 15, 2022
395e743
Test merge phase, plus minor XSLT enhancements (#1207)
galtm May 4, 2022
c022f30
Publishing generated metaschema resources [ci skip]
david-waltermire-nist May 17, 2022
3b6d09b
Support for control mapping (#1150)
david-waltermire Jul 5, 2022
c3f071f
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Jul 5, 2022
e435681
Update metaschema
david-waltermire Jul 6, 2022
30bbdba
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Jul 6, 2022
b580c29
Bump ajv-cli from 4.2.0 to 5.0.0 in /build (#1354)
dependabot[bot] Jul 13, 2022
93fba71
Bump peter-evans/create-issue-from-file from 3.0.0 to 4 (#1355)
dependabot[bot] Jul 13, 2022
1fe199e
Bump actions/setup-java from 2 to 3 (#1360)
dependabot[bot] Jul 13, 2022
8a7861e
Bump actions/setup-node from 2 to 3 (#1359)
dependabot[bot] Jul 13, 2022
68df9f1
Bump stefanzweifel/git-auto-commit-action from 4.9.2 to 4.14.1 (#1357)
dependabot[bot] Jul 13, 2022
fecbe3c
Bump github.com/gohugoio/hugo from 0.83.1 to 0.101.0 in /build (#1358)
dependabot[bot] Jul 14, 2022
a199209
Updating to latest metaschema toolchain. Resolves 1338
david-waltermire Jul 14, 2022
84d2d46
Fixes to correct metaschema validation errors.
david-waltermire Jul 14, 2022
c3674b6
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Jul 14, 2022
29a7f7a
Bump Saxon-HE from 10.6 to 10.8 in /build (#1375)
dependabot[bot] Jul 15, 2022
d8181a0
Bump actions/setup-node from 3.4.0 to 3.4.1 (#1374)
dependabot[bot] Jul 15, 2022
d8a7b03
Bump xmlcalabash from 1.2.5-100 to 1.4.1-100 in /build (#1363)
dependabot[bot] Jul 15, 2022
de301e5
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)
dependabot[bot] Jul 15, 2022
4e5296a
Update metaschema-docs
david-waltermire Jul 22, 2022
3b5e6a2
Profile Resolution Spec clarification: validation of imported catalog…
wendellpiez Jul 25, 2022
c87f267
Clarify how to determine target catalog `oscal-version` (#1386)
david-waltermire Jul 25, 2022
1212030
Profile Resolution spec: updated names of 'remove' directives (#1381)
wendellpiez Jul 25, 2022
bd33bf7
Test finish phase, plus minor XSLT enhancements and fixes (#1377)
galtm Jul 25, 2022
930fdac
Follow keep instruction for back-matter resources (#1378)
galtm Jul 25, 2022
01916ee
Bump lycheeverse/lychee-action from 1.5.0 to 1.5.1 (#1390)
dependabot[bot] Aug 11, 2022
f3df74b
Bump golang from 1.18.4-bullseye to 1.19.0-bullseye in /build (#1402)
dependabot[bot] Aug 11, 2022
b70886e
Add remarks field to Profile model modify.alter (add/remove). #1018 (…
Aug 11, 2022
d93ecdb
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Aug 11, 2022
b413079
Profile alter model adjustments (#1418)
david-waltermire Aug 17, 2022
0c1720d
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Aug 17, 2022
2d68868
Added legacy Withdrawn status with deprecation entry (#1419)
david-waltermire Aug 18, 2022
967c1bc
Bump actions/github-script from 6.1.0 to 6.1.1 (#1415)
dependabot[bot] Aug 21, 2022
05082b1
Add grouping construct to props for usnistgov/OSCAL#1064. (#1412)
aj-stein-nist Aug 21, 2022
6d19f84
Updates mapping model documentation to fix a copy and paste error. (#…
david-waltermire Aug 21, 2022
1b53dd9
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Aug 21, 2022
32fbf44
Add assessment-assets assembly to local-definitions assembly in POAM …
Aug 21, 2022
e77b4d9
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Aug 21, 2022
81cd54e
Fixing broken links
david-waltermire Aug 23, 2022
522a9de
Fixed broken links.
david-waltermire Aug 23, 2022
753b485
More broken link fixes.
david-waltermire Aug 23, 2022
f034b0e
Adding link to whitelist
david-waltermire Aug 23, 2022
ba6ca74
Bump actions/cache from 3.0.5 to 3.0.8 (#1422)
dependabot[bot] Aug 23, 2022
feb8356
Bump actions/setup-go from 3.2.0 to 3.3.0 (#1425)
dependabot[bot] Aug 25, 2022
c040810
Create `<define-assembly name="impact">` (fix #1129) (#1171)
guyzyl Aug 25, 2022
290f476
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Aug 25, 2022
ca4e5d3
imported-from relations for usnistgov/OSCAL#1023. (#1403)
aj-stein-nist Aug 31, 2022
b231958
Fixed errors in profile resolution top-level tests based on content e…
david-waltermire Sep 9, 2022
c38aa86
Update metaschema submodule for usnistgov/OSCAL#1454. (#1455)
aj-stein-nist Sep 19, 2022
a71fb59
Publishing generated metaschema resources [ci skip]
aj-stein-nist Sep 19, 2022
cf3f589
Added JSON value key for relationship type. This missing value key wa…
david-waltermire Sep 20, 2022
2da4e5f
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Sep 20, 2022
bb8f427
Add actions assembly to encode an action (i.e. approval) and its role…
aj-stein-nist Sep 26, 2022
a74ecba
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Sep 26, 2022
0890e8e
Implement opr:oscal-version and v:compare functions. (#1420)
galtm Sep 27, 2022
d1902c3
Updates to OSCAL Metaschema documentation and constraints (#1263)
david-waltermire Sep 27, 2022
5359f23
Test modify phase, plus minor XSLT enhancements (#1321)
galtm Sep 27, 2022
aabdf59
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Sep 27, 2022
d3e8b7c
Bump actions/cache from 3.0.8 to 3.0.10 (#1486)
dependabot[bot] Oct 4, 2022
1151670
Bump ncipollo/release-action from 1.10.0 to 1.11.0 (#1487)
dependabot[bot] Oct 4, 2022
58c0480
Bump actions/github-script from 6.1.1 to 6.3.1 (#1485)
dependabot[bot] Oct 4, 2022
ad55bb8
Bump actions/setup-node from 3.4.1 to 3.5.0 (#1481)
dependabot[bot] Oct 4, 2022
6f917b3
Bump actions/setup-java from 3.4.1 to 3.5.1 (#1476)
dependabot[bot] Oct 4, 2022
7f743f1
Bump actions/checkout from 3.0.2 to 3.1.0 (#1488)
dependabot[bot] Oct 4, 2022
154fedb
Bump stefanzweifel/git-auto-commit-action from 4.14.1 to 4.15.0 (#1472)
dependabot[bot] Oct 4, 2022
2ffcbc7
Bump golang from 1.19.0-bullseye to 1.19.1-bullseye in /build (#1446)
dependabot[bot] Oct 4, 2022
f9bd5c1
Updated data type documentation adding a note about why NCName was de…
david-waltermire Oct 4, 2022
d81db4f
Bump github.com/gohugoio/hugo from 0.101.0 to 0.104.3 in /build (#1489)
dependabot[bot] Oct 4, 2022
fe78fc4
Bump golang from 1.19.1-bullseye to 1.19.2-bullseye in /build (#1491)
dependabot[bot] Oct 5, 2022
b3ad45a
Bump xmlcalabash from 1.4.1-100 to 1.5.1-100 in /build (#1492)
dependabot[bot] Oct 5, 2022
c87aee2
Bump stefanzweifel/git-auto-commit-action from 4.15.0 to 4.15.1 (#1500)
dependabot[bot] Oct 11, 2022
96bae32
Bump actions/github-script from 6.3.1 to 6.3.2 (#1504)
dependabot[bot] Oct 12, 2022
f48ad70
Bump actions/github-script from 6.3.2 to 6.3.3 (#1510)
dependabot[bot] Oct 17, 2022
c692d39
Bump actions/cache from 3.0.10 to 3.0.11 (#1512)
dependabot[bot] Oct 17, 2022
ef5aa78
Bump actions/setup-node from 3.5.0 to 3.5.1 (#1511)
dependabot[bot] Oct 17, 2022
7c922c7
Support additional control-origination props #784 (#1460)
Oct 17, 2022
191fe2a
POAM related finding support, fixes #1120 (#1478)
Oct 17, 2022
c2e55c7
Publishing generated metaschema resources [ci skip]
david-waltermire-nist Oct 17, 2022
d9964a8
Fix broken uri-use page links in updated reference docs of develop br…
aj-stein-nist Oct 31, 2022
523f0be
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)…
dependabot[bot] Oct 31, 2022
c47ca47
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)…
dependabot[bot] Oct 31, 2022
02f8136
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)…
dependabot[bot] Oct 31, 2022
6af8024
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)…
dependabot[bot] Oct 31, 2022
005cbc3
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)…
dependabot[bot] Oct 31, 2022
198ba42
Publishing generated metaschema resources [ci skip]
oscalbuilder Oct 31, 2022
b82dbc1
Bump golang from 1.18.3-bullseye to 1.18.4-bullseye in /build (#1361)…
dependabot[bot] Nov 1, 2022
b8b41b5
Add profile checks with Schematron for usnistgov/oscal-content#128. (…
aj-stein-nist Nov 1, 2022
0737e61
reduced the amount of 'OSCAL' references in data type documentation. …
david-waltermire Nov 1, 2022
0ffe906
Bump peaceiris/actions-gh-pages from 3.8.0 to 3.9.0 (#1537)
dependabot[bot] Nov 1, 2022
edad841
Bump actions/upload-artifact from 3.1.0 to 3.1.1 (#1536)
dependabot[bot] Nov 1, 2022
66c5183
Bump stefanzweifel/git-auto-commit-action from 4.15.1 to 4.15.3 (#1535)
dependabot[bot] Nov 1, 2022
8d1c987
Add possible Schematron documentation checks (#1501)
aj-stein-nist Nov 1, 2022
7d7a672
Publishing generated metaschema resources [ci skip]
oscalbuilder Nov 1, 2022
295c609
Added resource-fragment flag to link. (#1527)
david-waltermire Nov 1, 2022
1a6f5cd
Publishing generated metaschema resources [ci skip]
oscalbuilder Nov 1, 2022
1ac9ce6
Bump golang from 1.19.2-bullseye to 1.19.3-bullseye in /build (#1538)
dependabot[bot] Nov 2, 2022
39b9d8e
Adds a constraint and index of by-component objects to support provid…
Nov 2, 2022
c24dd1e
Bump actions/setup-java from 3.6.0 to 3.7.0 (#1566)
dependabot[bot] Dec 7, 2022
d104822
Bump ncipollo/release-action from 1.11.0 to 1.11.2 (#1565)
dependabot[bot] Dec 7, 2022
f12ffb3
Bump actions/setup-go from 3.3.1 to 3.4.0 (#1564)
dependabot[bot] Dec 7, 2022
05a6b8a
Bump stefanzweifel/git-auto-commit-action from 4.15.3 to 4.16.0 (#1563)
dependabot[bot] Dec 7, 2022
0e29a87
Bump maven-dependency-plugin from 3.3.0 to 3.4.0 in /build (#1562)
dependabot[bot] Dec 7, 2022
672df8e
Bump github.com/gohugoio/hugo from 0.105.0 to 0.107.0 in /build (#1558)
dependabot[bot] Dec 7, 2022
2b227ac
Bump lycheeverse/lychee-action from 1.5.1 to 1.5.4 (#1547)
dependabot[bot] Dec 7, 2022
1eac90e
Bump actions/setup-java (#1576)
dependabot[bot] Dec 7, 2022
1f1336b
Bump github.com/gohugoio/hugo from 0.107.0 to 0.108.0 in /build (#1578)
dependabot[bot] Dec 7, 2022
2569057
Bump golang from 1.19.3-bullseye to 1.19.4-bullseye in /build (#1577)
dependabot[bot] Dec 7, 2022
bbdb74d
Fixed syntax errors in metapaths (#1574)
david-waltermire Dec 7, 2022
46700ba
Fixed improper use of allowed-values/allow-other. Ensured that all pr…
david-waltermire Dec 7, 2022
1a21bcf
Bump xmlcalabash from 1.5.1-100 to 1.5.3-110 in /build (#1575)
dependabot[bot] Dec 7, 2022
eb38225
Publishing generated metaschema resources [ci skip]
oscalbuilder Dec 7, 2022
2fbaae0
Fix rel path from XSLT transform source issue, fix usnistgov/OSCAL#16…
aj-stein-nist Jan 9, 2023
dd6486a
Fix Docker container build for local dev and debugging (#1598)
aj-stein-nist Jan 9, 2023
c36fd37
Bump actions/setup-go from 3.4.0 to 3.5.0 (#1586)
dependabot[bot] Jan 11, 2023
f977fea
Bump actions/cache from 3.0.11 to 3.2.3 (#1607)
dependabot[bot] Jan 11, 2023
5983454
Bump docs/themes/uswds from `631e114` to `ac7915f` (#1606)
dependabot[bot] Jan 11, 2023
265a541
Bump actions/checkout from 3.1.0 to 3.3.0 (#1601)
dependabot[bot] Jan 11, 2023
726ee96
Bump actions/setup-java from 3.8.0 to 3.9.0 (#1587)
dependabot[bot] Jan 11, 2023
b959aec
Bump ncipollo/release-action from 1.11.2 to 1.12.0 (#1583)
dependabot[bot] Jan 11, 2023
7bb0342
Bump golang from 1.19.4-bullseye to 1.19.5-bullseye in /build (#1609)
dependabot[bot] Jan 11, 2023
6ba5bcf
Bump github.com/gohugoio/hugo from 0.108.0 to 0.109.0 in /build (#1593)
dependabot[bot] Jan 11, 2023
50f9b82
Bump peaceiris/actions-gh-pages from 3.9.0 to 3.9.1 (#1610)
dependabot[bot] Jan 12, 2023
1caa849
Bump maven-dependency-plugin from 3.4.0 to 3.5.0 in /build (#1613)
dependabot[bot] Jan 12, 2023
e2db9e4
Bump actions/upload-artifact from 3.1.1 to 3.1.2 (#1612)
dependabot[bot] Jan 12, 2023
fee6dd1
Bump actions/setup-node from 3.5.1 to 3.6.0 (#1611)
dependabot[bot] Jan 12, 2023
4d9c460
Bump peaceiris/actions-gh-pages from 3.9.1 to 3.9.2 (#1616)
dependabot[bot] Jan 19, 2023
45e1c2c
Bump github.com/gohugoio/hugo from 0.109.0 to 0.110.0 in /build (#1617)
dependabot[bot] Jan 23, 2023
5afde6c
Bump actions/github-script from 6.3.3 to 6.4.0 (#1628)
dependabot[bot] Jan 27, 2023
20fb9b6
[WIP] Test out usnistgov/metaschema#253 fix for usnistgov/metaschema#…
aj-stein-nist Jan 31, 2023
8442852
Merge pull request #284 from aj-stein-nist/chore-update-metaschema-su…
aj-stein-nist Feb 1, 2023
aed20d4
Publishing generated metaschema resources [ci skip]
oscalbuilder Feb 1, 2023
196d4b4
Bump actions/checkout from 3.3.0 to 3.5.3
dependabot[bot] Jun 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test merge phase, plus minor XSLT enhancements (usnistgov#1207)
XSLT
- Move some code from oscal-profile-resolve-select.xsl to new file, select-or-custom-merge.xsl, and share it between Selection phase and Merge phase.
- Add error checking for multiple structuring directives.
- Finish the incomplete support for `insert-controls/@order`.
- Fix bug in support for `@with-parent-controls` in Selection phase.

XSpec
- In select.xspec, add test for order of controls matching imported document, not profile document. Also, add test for `@with-parent-controls` bug fix.
- Create merge-combine.xspec for testing combine-elements and mode="o:combine-elements" templates.
- Organize tests among merge.xspec, merge-combine.xspec, merge-as-is.xspec, and merge-custom.xspec.
- Integrate back-matter testing into template-level tests in merge.xspec and merge-as-is.xspec, and delete merge-back-matter.xspec.
  • Loading branch information
galtm authored and aj-stein-nist committed Jan 10, 2023
commit 395e743e20429d756e85ba03b00cef7570b2eff0
153 changes: 94 additions & 59 deletions src/utils/util/resolver-pipeline/oscal-profile-resolve-merge.xsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
<xsl:stylesheet version="3.0"
xmlns="http://csrc.nist.gov/ns/oscal/1.0"
xmlns:mh="http://csrc.nist.gov/ns/message"
xmlns:o="http://csrc.nist.gov/ns/oscal/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
@@ -9,8 +10,10 @@
exclude-result-prefixes="xs math o opr"
xpath-default-namespace="http://csrc.nist.gov/ns/oscal/1.0" >

<!-- XSLT 2.0 so as to validate against XSLT 3.0 constructs -->
<xsl:import href="message-handler.xsl"/>

<xsl:variable name="in_xspec" as="xs:boolean" select="false()"/>
<xsl:variable name="true-content" as="xs:string+" select="('true','1')"/>

<xsl:template match="* | @*" mode="#all">
<xsl:copy copy-namespaces="no">
@@ -25,34 +28,43 @@
templates not this one. -->
</xsl:template>

<xsl:template match="catalog" priority="2">
<!-- If there is no selection and no merge (i.e., we don't reach one of
the higher-priority templates that match catalog), pass the catalog
through unchanged. -->
<xsl:template match="catalog" priority="2" as="element(catalog)">
<xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="catalog[exists(selection)]" priority="10">
<!-- If there is a selection but neither merge/as-is nor merge/custom,
use flat structuring. -->
<xsl:template match="catalog[exists(selection)]" priority="10" as="element(catalog)">
<catalog>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="metadata"/>
<xsl:apply-templates select="selection"/>
<xsl:apply-templates select="modify"/>
<xsl:for-each-group select="back-matter/* | selection/back-matter/*" group-by="true()">
<xsl:where-populated>
<back-matter>
<xsl:copy-of select="current-group()"/>
<xsl:sequence select="back-matter/* | selection/back-matter/*"/>
</back-matter>
</xsl:for-each-group>
</xsl:where-populated>
</catalog>
</xsl:template>

<xsl:template priority="12" match="catalog[merge/as-is=('true','1')]">
<!-- If there is a merge/as-is directive, we go down that branch.
If there is also a merge/custom directive, we apply the
higher-priority template instead of this one. -->
<xsl:template match="catalog[merge/as-is=$true-content]" priority="12" as="element(catalog)">
<xsl:call-template name="detect-multiple-structuring-directives"/>
<catalog>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="metadata"/>
<xsl:variable name="merged-selections">
<xsl:call-template name="o:merge-groups-as-is">
<xsl:with-param name="merging" select="selection"/>
</xsl:call-template>
<xsl:call-template name="o:merge-groups-as-is">
<xsl:with-param name="merging" select="selection"/>
</xsl:call-template>
</xsl:variable>
<!-- not copying the selection elements only their contents -->
<!-- not copying the selection elements, only their contents -->
<xsl:for-each select="$merged-selections/selection">
<xsl:sequence select="* except back-matter"/>
</xsl:for-each>
@@ -64,7 +76,8 @@


<!-- If there is a merge/custom directive, we go down that branch. -->
<xsl:template priority="13" match="catalog[exists(merge/custom)]">
<xsl:template match="catalog[exists(merge/custom)]" priority="13" as="element(catalog)">
<xsl:call-template name="detect-multiple-structuring-directives"/>
<catalog>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="metadata"/>
@@ -77,83 +90,93 @@
</catalog>
</xsl:template>

<xsl:template name="combine-back-matter">
<xsl:variable name="here" select="self::catalog"/>
<xsl:for-each-group select="back-matter/* | selection/back-matter/*" group-by="true()">
<xsl:template name="detect-multiple-structuring-directives" as="empty-sequence()">
<xsl:context-item as="element(catalog)" use="required"/>
<xsl:variable name="flat" as="element(flat)*" select="merge/flat[.=$true-content]"/>
<xsl:variable name="as-is" as="element(as-is)*" select="merge/as-is[.=$true-content]"/>
<xsl:variable name="custom" as="element(custom)*" select="merge/custom"/>
<xsl:if test="count($flat) + count($as-is) + count($custom) gt 1">
<xsl:call-template name="mh:message-handler">
<xsl:with-param name="text">Found multiple structuring directives. Choose at most one from: flat (default), as-is, custom.</xsl:with-param>
<xsl:with-param name="message-type">Error</xsl:with-param>
<xsl:with-param name="terminate" select="true()"/>
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="combine-back-matter" as="element(back-matter)?">
<xsl:context-item as="element(catalog)" use="required"/>
<xsl:where-populated>
<back-matter>
<!-- Using combination logic on back matter elements. -->
<xsl:for-each-group select="current-group()" group-by="(@opr:id,@id,generate-id())[1]">
<xsl:for-each-group select="back-matter/* | selection/back-matter/*" group-by="(@opr:id,@uuid,generate-id())[1]">
<xsl:call-template name="combine-elements">
<xsl:with-param name="who" select="current-group()"/>
<!-- Take last one in group because of spec
requirement id="req-backmatter-dupe". -->
<xsl:with-param name="who" select="current-group()[last()]" as="element(resource)"/>
</xsl:call-template>
</xsl:for-each-group>
</back-matter>
</xsl:for-each-group>
</xsl:where-populated>
</xsl:template>

<xsl:template match="selection">
<xsl:apply-templates select="param | .//group/param"/>
<xsl:apply-templates select="control | .//group/control"/>
</xsl:template>

<xsl:key name="control-by-id" match="control" use="@id"/>

<xsl:template match="node() | @*" mode="o:custom-merge">
<xsl:copy>
<xsl:apply-templates mode="#current" select="node() | @*"/>
</xsl:copy>
</xsl:template>

<!-- Process children but do not copy <custom> tags themselves. -->
<xsl:template match="custom" mode="o:custom-merge">
<xsl:apply-templates mode="#current"/>
</xsl:template>

<!-- Apply the requested ordering.
Creating the properly combined sequence of inserted controls
is in downstream template. -->
<xsl:template match="insert-controls" mode="o:custom-merge">
<xsl:variable name="inserted-controls">
<xsl:variable name="inserted-controls" as="element()*">
<xsl:apply-templates mode="#current"/>
</xsl:variable>
<xsl:variable name="keep-order" select="not(@order = ('descending','ascending'))" as="xs:boolean"/>
<xsl:variable name="sort-order" select="@order[.='descending'],'ascending'"/>
<!-- Setting sort-key to '1' sorts into given order -->
<xsl:perform-sort select="$inserted-controls">
<xsl:sort select="if ($keep-order) then '1' else @control-id"/>
<xsl:perform-sort select="$inserted-controls">
<xsl:sort select="if ($keep-order) then '1' else @id"
order="{$sort-order[1]}"/>
</xsl:perform-sort>
</xsl:template>

<xsl:template match="include-controls" mode="o:custom-merge">
<xsl:variable name="match-patterns" select="matching/@pattern"/>
<xsl:call-template name="combine-elements">
<xsl:with-param name="who" select="key('control-by-id', with-id),
/*/selection//control[some $p in ($match-patterns) satisfies (matches(@id,o:glob-as-regex(string($p))))]"/>
</xsl:call-template>
</xsl:template>
<xsl:include href="select-or-custom-merge.xsl"/>

<xsl:template match="include-all" mode="o:custom-merge">
<xsl:variable name="match-patterns" select="matching/@pattern"/>
<!-- Combine selected controls.
Creating the sequence of controls ($who) is in code shared with
selection phase. -->
<xsl:template match="include-all | include-controls" mode="o:custom-merge">
<xsl:variable name="who" as="element(o:control)*">
<xsl:apply-templates select="ancestor::*[last()]//selection" mode="o:select">
<xsl:with-param tunnel="yes" name="import-instruction" select="ancestor::insert-controls"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:call-template name="combine-elements">
<xsl:with-param name="who" select="//control"/>
<xsl:with-param name="who" select="$who"/>
</xsl:call-template>
</xsl:template>

<xsl:include href="oscal-profile-resolve-functions.xsl"/>
<!-- No-op because exclusion logic is handled in the code shared with
selection phase. -->
<xsl:template match="exclude-controls" mode="o:custom-merge"/>

<!--<xsl:template match="with-id">
<xsl:call-template name="combine-elements">
<xsl:with-param name="who" select="key('control-by-id', @control-id)"/>
</xsl:call-template>
<!-- In o:select mode, process children of selection or group to reach
controls, which are handled in select-or-custom-merge.xsl. -->
<xsl:template match="selection | selection//group" mode="o:select">
<xsl:apply-templates select="group | control" mode="#current"/>
</xsl:template>

<xsl:template match="matching" mode="o:custom-merge">
<xsl:variable name="p" select="@pattern"/>
<xsl:call-template name="combine-elements">
<xsl:with-param name="who" select="/*/selection//control[matches(@id,$p)]"/>
</xsl:call-template>
</xsl:template>-->

<xsl:template name="o:merge-groups-as-is">
<xsl:param name="merging" select="()"/>
<xsl:context-item as="element()" use="optional"/>
<xsl:param name="merging" select="()" as="element()*"/>
<xsl:for-each-group select="$merging" group-by="(@uuid,@opr:id,@id,generate-id())[1]">
<xsl:variable name="merged" select="current-group()"/>
<xsl:variable name="merged" select="current-group()" as="element()+"/>
<xsl:for-each select="$merged[1]">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="$merged/@*"/>
@@ -177,6 +200,7 @@
</xsl:template>

<xsl:template name="combine-elements">
<xsl:context-item as="element()" use="required"/>
<xsl:param name="who" as="element()*"/>
<xsl:apply-templates select="ancestor-or-self::catalog" mode="o:combine-elements">
<xsl:with-param name="elements" select="$who"/>
@@ -194,15 +218,26 @@
<!-- All the elements coming in have the same name but different opr:id
we operate on controls and parameters (not groups or group contents otherwise) -->
<!-- further, we assume all controls or all parameters -->
<xsl:if test="$elements/name() != $elements/name()">
<opr:error> ... elements of different types combining ...</opr:error></xsl:if>
<xsl:variable name="uri-qualified-name" as="function(*)"
select="function($node as element()) as xs:string {
'Q{' || namespace-uri($node) || '}' || local-name($node)
}"/>
<xsl:variable name="element-names" as="xs:string*"
select="$elements ! $uri-qualified-name(.)"/>
<xsl:if test="$element-names != $element-names">
<!-- If we get here for a valid profile, it is an XSLT bug rather than a user error. -->
<xsl:call-template name="mh:message-handler">
<xsl:with-param name="text">Combining elements of different types is not supported.</xsl:with-param>
<xsl:with-param name="message-type">Error</xsl:with-param>
<xsl:with-param name="terminate" select="$in_xspec"/>
</xsl:call-template>
</xsl:if>
<xsl:for-each-group select="$elements" group-by="(@opr:id,@id,generate-id())[1]">
<xsl:variable name="merged" select="current-group()"/>
<xsl:variable name="merged" select="current-group()" as="element()+"/>
<xsl:for-each select="$merged[1]">
<xsl:copy copy-namespaces="no">
<xsl:apply-templates select="$merged/@*"/>
<xsl:apply-templates select="$merged/*"/>

</xsl:copy>
</xsl:for-each>
</xsl:for-each-group>
@@ -219,7 +254,7 @@
<xsl:apply-templates select="$elements"/>
</xsl:template>

<!-- Scrubbing opr:id values on the way out - we don't need them. -->
<!-- Scrubbing opr:id values on the way out - we don't need them. -->
<xsl:template match="@opr:id"/>

</xsl:stylesheet>
80 changes: 2 additions & 78 deletions src/utils/util/resolver-pipeline/oscal-profile-resolve-select.xsl
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@
<xsl:variable name="linked-xml" select="child::rlink[ends-with(@href,'.xml') or matches(@media-type,'xml')][1]"/>
<xsl:choose>
<xsl:when test="exists($linked-xml)">
<xsl:apply-templates mode="o:select" select="o:resource-or-error($linked-xml/@href)"/>
<xsl:apply-templates mode="o:select" select="o:resource-or-error($linked-xml/@href)"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes"
@@ -126,30 +126,6 @@
</xsl:copy>
</xsl:template>

<xsl:template name="add-process-id" as="attribute(opr:id)">
<xsl:param name="context" select="." as="element()"/>
<xsl:attribute name="opr:id" namespace="http://csrc.nist.gov/ns/oscal/profile-resolution">
<xsl:value-of
select="concat(opr:catalog-identifier($context/root()/o:catalog), '#', $context/(@id, generate-id())[1])"/>
</xsl:attribute>
</xsl:template>

<xsl:function name="opr:catalog-identifier" as="xs:string">
<xsl:param name="catalog" as="element(o:catalog)"/>
<xsl:sequence select="$catalog/(@uuid,document-uri(root(.)))[1]"/>
</xsl:function>

<!-- A control is included if it is selected by the provided import instruction -->
<xsl:template match="control" mode="o:select" as="element(o:control)?">
<xsl:param name="import-instruction" tunnel="yes" required="yes"/>
<xsl:if test="o:selects($import-instruction,.)">
<xsl:copy copy-namespaces="no">
<xsl:call-template name="add-process-id"/>
<xsl:apply-templates mode="#current" select="node() | @*"/>
</xsl:copy>
</xsl:if>
</xsl:template>

<!-- Parameters are always passed through until later stages. -->
<xsl:template match="param" mode="o:select">
<xsl:copy copy-namespaces="no">
@@ -170,58 +146,6 @@
</xsl:if>
</xsl:template>-->

<!-- Function o:selects($importing,$candidate) returns a true or false
depending on whether the import calls the candidate control -->

<!-- @with-child-controls='yes' is recursive - given on a control it brings all control descendants, not only children -->
<xsl:function name="o:selects" as="xs:boolean">
<xsl:param name="importing" as="element(o:import)"/>
<xsl:param name="candidate" as="element(o:control)"/>
<xsl:variable name="include-reasons" as="xs:boolean+">
<!-- we are not optimizing for performance here; nothing is done to prevent all checks even if the first passes -->
<!--<xsl:sequence select="empty($importing/include)"/>-->
<xsl:sequence select="exists($importing/include-all)"/>
<xsl:sequence select="some $c in ($importing/include-controls/with-id)
satisfies ($c = $candidate/@id)"/>
<xsl:sequence select="some $c in ($importing/include-controls[o:calls-parents(.)]/with-id)
satisfies ($c = $candidate/descendant::control/@id)"/>
<xsl:sequence select="some $c in ($importing/include-controls[o:calls-children(.)]/with-id)
satisfies ($c = $candidate/ancestor::control/@id)"/>
<xsl:sequence select="some $m in ($importing/include-controls/matching[@pattern != ''])
satisfies (matches($candidate/@id,$m/@pattern/o:glob-as-regex(string(.)) ))"/>
<xsl:sequence select="some $m in ($importing/include-controls[o:calls-parents(.)]/matching[@pattern != '']), $a in $candidate/descendant::control
satisfies (matches($a/@id,$m/@pattern/o:glob-as-regex(string(.))))"/>
<xsl:sequence select="some $m in ($importing/include-controls[o:calls-children(.)]/matching[@pattern != '']), $a in $candidate/ancestor::control
satisfies (matches($a/@id,$m/@pattern/o:glob-as-regex(string(.))))"/>
</xsl:variable>
<xsl:variable name="exclude-reasons" as="xs:boolean+">
<xsl:sequence select="exists($candidate/parent::control) and $importing/include-all/@with-child-controls='no'"/>
<xsl:sequence select="some $c in ($importing/exclude-controls/with-id) satisfies ($c = $candidate/@id)"/>
<xsl:sequence select="some $c in ($importing/exclude-controls[o:calls-parents(.)]/with-id)
satisfies ($c = $candidate/descendant::control/@id)"/>
<xsl:sequence select="some $c in ($importing/exclude-controls[o:calls-children(.)]/with-id)
satisfies ($c = $candidate/ancestor::control/@id)"/>
<xsl:sequence select="some $m in ($importing/exclude-controls/matching[@pattern != ''])
satisfies (matches($candidate/@id,$m/@pattern/o:glob-as-regex(string(.))))"/>
<xsl:sequence select="some $m in ($importing/exclude-controls[o:calls-parents(.)]/matching[@pattern != '']), $a in $candidate/descendant::control
satisfies (matches($a/@id,$m/@pattern/o:glob-as-regex(string(.))))"/>
<xsl:sequence select="some $m in ($importing/exclude-controls[o:calls-children(.)]/matching[@pattern != '']), $a in $candidate/ancestor::control
satisfies (matches($a/@id,$m/@pattern/o:glob-as-regex(string(.))))"/>
</xsl:variable>
<!-- predicate [.] filters reasons as booleans -->
<xsl:sequence select="exists($include-reasons[.]) and empty($exclude-reasons[.])"/>
</xsl:function>

<xsl:function name="o:calls-children" as="xs:boolean">
<xsl:param name="caller" as="element()"/>
<xsl:sequence select="$caller/@with-child-controls='yes'"/>
</xsl:function>

<xsl:function name="o:calls-parents" as="xs:boolean">
<xsl:param name="caller" as="element()"/>
<xsl:sequence select="not($caller/@with-parent-controls='no')"/>
</xsl:function>

<!-- Returns a document when found, a fatal error when not. -->
<xsl:function name="o:resource-or-error" as="document-node()">
<xsl:param name="href" as="attribute(href)"/>
@@ -232,7 +156,7 @@
<xsl:sequence select="document($resolved-href)"/>
</xsl:function>

<xsl:include href="oscal-profile-resolve-functions.xsl"/>
<xsl:include href="select-or-custom-merge.xsl"/>

<xsl:function name="o:resolve-profile">
<xsl:param name="profile" as="element(profile)"/>
Loading