Skip to content

Hardening#169

Open
peterstadler wants to merge 27 commits into
developfrom
hardening
Open

Hardening#169
peterstadler wants to merge 27 commits into
developfrom
hardening

Conversation

@peterstadler
Copy link
Copy Markdown
Member

Description, Context and related Issue

Allowing to load arbitrary XML files (from anywhere) is a major security issue in the XML world and should be avoided.
This PR updates the function eutil:getDoc#1 to only load files from the local database and replaces all direct calls to the doc-function with the hardened wrapper function eutil:getDoc#1.

How Has This Been Tested?

I tested this by starting two Docker containers:

  • a reference container from current edirom/edirom-online-backend:develop image
  • a test container from a local image of the current PR

I then loaded the same clarinet quintet data xar into both containers and ran the following script which simply curls some endpoints and diffs the changes:

#!/bin/bash

#REFERENCE_BASE=https://klarinettenquintett.weber-gesamtausgabe.de
REFERENCE_BASE=http://localhost:8090/exist/apps/Edirom-Online-Backend
TEST_BASE=http://localhost:8080/exist/apps/Edirom-Online-Backend

declare -a ENDPOINTS=(
"/data/xql/getPreferences.xql?_dc=1777986768638&mode=json&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=en"
"/data/xql/getPreferences.xql?_dc=1777986768638&mode=json&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getText.xql?_dc=1777986672408&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Ftexts%2Ftext-5.xml&idPrefix=textView-1254_&term=&path=&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getPages.xql?_dc=1777986349264&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getLanguageFile.xql?_dc=1777986768641&lang=de&mode=json&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml"
"/data/xql/getEdition.xql?_dc=1777986768657&id=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&page=1&start=0&limit=25"
"/data/xql/getWorks.xql?_dc=1777986768658&editionId=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de&page=1&start=0&limit=25"
"/data/xql/getNavigatorConfig.xql?_dc=1777986768685&editionId=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&workId=edition-27830471_work-1&lang=de&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml"
"/data/xql/getText.xql?_dc=1777986769008&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Ftexts%2Ftext-1.xml&idPrefix=textView-1063_&term=&path=&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getAnnotationInfos.xql?_dc=1777986769347&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Ftexts%2Ftext-1.xml&lang=de&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml"
"/data/xql/getMovements.xql?_dc=1777987885724&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-8.xml&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getMovements.xql?_dc=1777987923059&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-4-MEI.xml&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getAnnotationInfos.xql?_dc=1777988007718&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&lang=de&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml"
"/data/xql/getMeasuresOnPage.xql?_dc=1777988049539&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&pageId=facsimile-2001002&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
"/data/xql/getAnnotationsOnPage.xql?_dc=1777988049541&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&pageId=facsimile-2001002&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de"
)

for i in "${ENDPOINTS[@]}"
do
    REF_FILE=`mktemp`
    TEST_FILE=`mktemp`
    echo "testing $i"
    curl -Ls $REFERENCE_BASE$i -o $REF_FILE
    curl -Ls $TEST_BASE$i -o $TEST_FILE
    diff $REF_FILE $TEST_FILE
    rm $REF_FILE $TEST_FILE
done

The output from looks good – there are only some expected differences in the @src attributes:

testing /data/xql/getPreferences.xql?_dc=1777986768638&mode=json&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=en
testing /data/xql/getPreferences.xql?_dc=1777986768638&mode=json&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
testing /data/xql/getText.xql?_dc=1777986672408&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Ftexts%2Ftext-5.xml&idPrefix=textView-1254_&term=&path=&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
43c43
<             <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/rondofolgt.jpg" alt="" class="graphic" /></figure>
---
>             <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/rondofolgt.jpg" alt="" class="graphic" /></figure>
50c50
<             <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/eberstitel.jpg" alt="" class="graphic" />
---
>             <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/eberstitel.jpg" alt="" class="graphic" />
66c66
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/mockwitz_titel.jpg" alt="" class="graphic" />
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/mockwitz_titel.jpg" alt="" class="graphic" />
74c74
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann_titel.jpg" alt="" class="graphic" />
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann_titel.jpg" alt="" class="graphic" />
84c84
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann01.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann01.jpg" alt="" class="graphic" /></figure>
87c87
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann02.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann02.jpg" alt="" class="graphic" /></figure>
90c90
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann03.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann03.jpg" alt="" class="graphic" /></figure>
93c93
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann04.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann04.jpg" alt="" class="graphic" /></figure>
95c95
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann05.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann05.jpg" alt="" class="graphic" /></figure>
97c97
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann06.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/baermann06.jpg" alt="" class="graphic" /></figure>
101c101
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/stimmenbaerm_titel.jpg" alt="" class="graphic" />
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/stimmenbaerm_titel.jpg" alt="" class="graphic" />
109c109
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/hermann_titel.jpg" alt="" class="graphic" />
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/hermann_titel.jpg" alt="" class="graphic" />
114c114
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/JansenReduz-1.jpg" alt="" class="graphic" />
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/JansenReduz-1.jpg" alt="" class="graphic" />
121c121
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/hausswald1.jpg" alt="" class="graphic" />
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/hausswald1.jpg" alt="" class="graphic" />
125c125
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/meyertitel.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/meyertitel.jpg" alt="" class="graphic" /></figure>
127c127
<                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8090/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/eulenburg.jpg" alt="" class="graphic" /></figure>
---
>                 <figure class="figure"><img xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:functx="http://www.functx.com" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" src="http://localhost:8080/exist/apps/weber-klarinettenquintett-eol-emeritus/texts/../figures/eulenburg.jpg" alt="" class="graphic" /></figure>
testing /data/xql/getPages.xql?_dc=1777986349264&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
testing /data/xql/getLanguageFile.xql?_dc=1777986768641&lang=de&mode=json&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml
testing /data/xql/getEdition.xql?_dc=1777986768657&id=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&page=1&start=0&limit=25
testing /data/xql/getWorks.xql?_dc=1777986768658&editionId=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de&page=1&start=0&limit=25
testing /data/xql/getNavigatorConfig.xql?_dc=1777986768685&editionId=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&workId=edition-27830471_work-1&lang=de&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml
testing /data/xql/getText.xql?_dc=1777986769008&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Ftexts%2Ftext-1.xml&idPrefix=textView-1063_&term=&path=&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
testing /data/xql/getAnnotationInfos.xql?_dc=1777986769347&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Ftexts%2Ftext-1.xml&lang=de&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml
testing /data/xql/getMovements.xql?_dc=1777987885724&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-8.xml&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
testing /data/xql/getMovements.xql?_dc=1777987923059&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-4-MEI.xml&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
testing /data/xql/getAnnotationInfos.xql?_dc=1777988007718&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&lang=de&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml
testing /data/xql/getMeasuresOnPage.xql?_dc=1777988049539&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&pageId=facsimile-2001002&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de
testing /data/xql/getAnnotationsOnPage.xql?_dc=1777988049541&uri=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fsources%2Fsource-1.xml&pageId=facsimile-2001002&edition=xmldb%3Aexist%3A%2F%2F%2Fdb%2Fapps%2Fweber-klarinettenquintett-eol-emeritus%2Fedition.xml&lang=de

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement
  • Refactoring

Overview

  • I have updated the inline documentation accordingly.
  • I have performed a self-review of my code, according to the style guide
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes at testing
  • All new and existing tests passed.

only allow to load XML files from local eXist db
with hardened `eutil:getDoc#1`
with hardened `eutil:getDoc#1`
with hardened `eutil:getDoc#1`
and replace with hardened `eutil:getDoc#1`
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens XML document loading by restricting eutil:getDoc#1 to internal eXist-db URIs and updating multiple XQuery modules/endpoints to use this wrapper instead of calling doc() directly.

Changes:

  • Added URI validation + a dedicated error QName to eutil:getDoc#1 and introduced eutil:isInternalDbUri.
  • Replaced many direct doc(...) usages with eutil:getDoc(...) across data/xqm modules and data/xql endpoints.
  • Added missing eutil module imports in several data/xql scripts.

Reviewed changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
data/xqm/eutil.xqm Adds internal-URI enforcement in eutil:getDoc and introduces URI validation helper.
data/xqm/edition.xqm Switches edition parsing/helpers to use eutil:getDoc.
data/xqm/work.xqm Uses eutil:getDoc when loading work documents.
data/xqm/annotation.xqm Uses eutil:getDoc in annotationsToJSON (module still contains other doc() calls).
data/xql/getZone.xql Uses hardened document loader for MEI zone lookups.
data/xql/getXml.xql Uses hardened loader for returning document fragments by ID.
data/xql/getWorkID.xql Uses hardened loader for work ID resolution.
data/xql/getText.xql Uses hardened loader for text doc + XSLT loading during transforms.
data/xql/getSummary.xql Uses hardened loader for related work/image document loads.
data/xql/getReducedDocument.xql Loads source doc via hardened loader (still contains a direct doc() for PI-based XSLT).
data/xql/getPreferences.xql Loads default/project preferences via hardened loader.
data/xql/getParts.xql Loads MEI via hardened loader.
data/xql/getPages.xql Loads MEI via hardened loader (comment updated accordingly).
data/xql/getOverlays.xql Adds eutil import and uses hardened loader for MEI.
data/xql/getOverlayOnPage.xql Adds eutil import and uses hardened loader for MEI.
data/xql/getNavigatorConfig.xql Loads edition doc via hardened loader.
data/xql/getMusicInMdiv.xql Adds eutil import and uses hardened loader for MEI.
data/xql/getMovementsFirstPage.xql Adds eutil import and uses hardened loader for MEI.
data/xql/getMovements.xql Adds eutil import and uses hardened loader for MEI.
data/xql/getMeasuresOnPage.xql Adds eutil import and uses hardened loader for MEI.
data/xql/getMeasurePage.xql Adds eutil import (currently with an invalid module path).
data/xql/getMeasure.xql Adds eutil import (currently with an invalid module path).
data/xql/getLanguageFile.xql Loads locale/project language files via hardened loader (import path currently invalid).
data/xql/getInternalIdType.xql Loads document via hardened loader (import path currently invalid).
data/xql/getHelp.xql Loads help XML + XSLTs via hardened loader (import path currently invalid).
data/xql/getConcordances.xql Loads MEI via hardened loader.
data/xql/getAnnotationText.xql Loads annotation target doc via hardened loader.
data/xql/getAnnotationsOnPage.xql Loads source MEI via hardened loader.
data/xql/getAnnotations.xql Loads MEI once via hardened loader and reuses it for totals.
data/xql/getAnnotationPreviews.xql Loads docs via hardened loader when resolving referenced elements.
data/xql/getAnnotationOpenAllUris.xql Loads docs via hardened loader when resolving participants/ranges.
data/xql/getAnnotationMeta.xql Loads annotation doc via hardened loader.
data/xql/getAnnotationInfos.xql Loads MEI via hardened loader.
data/xql/getAnnotation.xql Uses hardened loader for multiple dereferences + fixes typos in docs/comments.
Comments suppressed due to low confidence (1)

data/xql/getReducedDocument.xql:45

  • This file still loads an XSLT referenced via xml-stylesheet processing instruction using a direct doc($xslInstruction) later in the query. That bypasses the hardened eutil:getDoc policy and can reintroduce remote/file URI loading via crafted input documents; switch to eutil:getDoc($xslInstruction) (or otherwise validate/allowlist the PI href).
let $doc := eutil:getDoc($uri)
let $xsl := '../xslt/reduceToSelection.xsl'

let $doc :=
    transform:transform($doc, $xsl,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread data/xqm/eutil.xqm Outdated
Comment thread data/xqm/eutil.xqm Outdated
Comment thread data/xqm/edition.xqm Outdated
Comment thread data/xqm/edition.xqm Outdated
Comment thread data/xql/getMeasurePage.xql Outdated
Comment thread data/xql/getMeasure.xql Outdated
Comment thread data/xql/getInternalIdType.xql Outdated
Comment thread data/xql/getHelp.xql Outdated
Comment thread data/xql/getLanguageFile.xql Outdated
Comment thread data/xqm/annotation.xqm
peterstadler and others added 10 commits May 20, 2026 09:54
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
with hardened `eutil:getDoc#1`
to prevent resolution attempts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Comment thread data/xqm/eutil.xqm
Comment thread data/xql/getReducedDocument.xql Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 7 comments.

Comment thread data/xql/getHelp.xql Outdated
Comment thread data/xql/getLanguageFile.xql Outdated
Comment thread data/xql/getReducedDocument.xql Outdated
Comment thread data/xql/getText.xql Outdated
Comment thread data/xql/getText.xql Outdated
Comment thread data/xqm/eutil.xqm
Comment thread data/xqm/eutil.xqm
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 5 comments.

Comment thread data/xql/getText.xql Outdated
Comment thread data/xql/getReducedDocument.xql Outdated
Comment thread data/xqm/edition.xqm
Comment thread data/xqm/edition.xqm
Comment thread data/xqm/annotation.xqm Outdated
peterstadler and others added 3 commits May 20, 2026 21:35
…id noisy logs

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…id noisy logs

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.

Comment thread data/xqm/annotation.xqm
Comment thread data/xql/getText.xql
@peterstadler peterstadler moved this from In Progress to Ready for Review in Edirom Development May 20, 2026
@peterstadler
Copy link
Copy Markdown
Member Author

Hi @fmacca , you may take over now, if you have some time to look into this.
Many thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

5 participants