Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
cp node_modules/@highlightjs/cdn-assets/es/languages/xml.min.js lib/xml.min.js
cp node_modules/@highlightjs/cdn-assets/es/languages/http.min.js lib/http.min.js
cp node_modules/@highlightjs/cdn-assets/es/languages/properties.min.js lib/properties.min.js
cp node_modules/pako/dist/pako_inflate.min.js lib/pako_inflate.min.js

- name: Clean release
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ lib/*.js
node_modules/
vendor/
composer.lock
test-results/
playwright-report/
37 changes: 0 additions & 37 deletions attribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,40 +53,3 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
```

---

pako
----

License type: MIT License

Project URL: https://github.com/nodeca/pako

Original license text:

```
(The MIT License)

Copyright (C) 2014-2017 by Vitaly Puzrin and Andrei Tuputcyn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

---
83 changes: 65 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
"version": "1.9.2",
"description": "A debugger for viewing SAML messages",
"scripts": {
"test": "jest"
"test": "jest",
"test:e2e": "playwright test"
},
"dependencies": {
"@highlightjs/cdn-assets": "11.11.1",
"pako": "~2.2"
"@highlightjs/cdn-assets": "11.11.1"
},
"devDependencies": {
"@playwright/test": "^1.59.1",
"jest": "^29.0.0"
},
"jest": {
"testEnvironment": "node"
"testEnvironment": "node",
"testMatch": ["**/*.test.js"]
}
}
11 changes: 11 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { defineConfig } = require('@playwright/test');

module.exports = defineConfig({
testDir: './test',
testMatch: '**/*.spec.js', // keep separate from Jest's *.test.js files
timeout: 60000,
reporter: 'list',
use: {
headless: false,
},
});
32 changes: 21 additions & 11 deletions src/SAMLTrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if ("undefined" == typeof(SAMLTrace)) {
var SAMLTrace = {};
};

SAMLTrace.b64inflate = function (data) {
SAMLTrace.b64inflate = async function (data) {
// Remove any whitespace in the base64-encoded data -- Shibboleth may insert line feeds in the data.
data = data.replace(/\s/g, '');

Expand All @@ -21,7 +21,8 @@ SAMLTrace.b64inflate = function (data) {

const decoded = atob(data);
const bytes = Uint8Array.from(decoded, c => c.charCodeAt(0));
const inflated = pako.inflateRaw(bytes);
const stream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream('deflate-raw'));
const inflated = new Uint8Array(await new Response(stream).arrayBuffer());
return String.fromCharCode.apply(String, inflated);
};

Expand Down Expand Up @@ -145,7 +146,9 @@ SAMLTrace.Request = function(request, getResponse) {
this.loadPOST(request);
this.parsePOST();
this.parseProtocol();
this.parseSAML();
// parseSAML() inflates the HTTP-Redirect binding via DecompressionStream and is therefore
// asynchronous. Callers must await it before rendering: RequestItem inspects `saml` and
// `samlart` to decide which tabs exist.
};
SAMLTrace.Request.prototype = {
'loadRequestHeaders' : function(request) {
Expand Down Expand Up @@ -269,7 +272,7 @@ SAMLTrace.Request.prototype = {
this.protocol = "WS-Fed";
}
},
'parseSAML' : function() {
'parseSAML' : async function() {
if ((this.saml && this.saml !== "") || (this.samlart && this.samlart !== "")) {
// do nothing if the token of an imported request is already present
return;
Expand Down Expand Up @@ -301,12 +304,17 @@ SAMLTrace.Request.prototype = {
return parameter ? parameter[1] : null;
};

return queries.some(query => {
// Sequential rather than Array.some(), because the inflating actions are asynchronous.
// Semantics are unchanged: every query up to and including the first match is applied.
for (const query of queries) {
let parameter = findParameter(query.name, query.collection);
let value = query.action(parameter);
let value = await query.action(parameter);
query.to(value);
return value !== null;
});
if (value !== null) {
return true;
}
}
return false;
}
};

Expand Down Expand Up @@ -645,8 +653,10 @@ SAMLTrace.TraceWindow.prototype = {
return false;
},

'addRequestItem' : function(request, getResponse) {
'addRequestItem' : async function(request, getResponse) {
var samlTracerRequest = new SAMLTrace.Request(request, getResponse);
// Parse before publishing the request, so nothing can observe a half-initialised entry.
await samlTracerRequest.parseSAML();
this.requests.push(samlTracerRequest);
request.parsed = samlTracerRequest;

Expand Down Expand Up @@ -760,7 +770,7 @@ SAMLTrace.TraceWindow.prototype = {

'attachHeadersToRequest' : function(request) { // onBeforeSendHeaders
let uniqueRequestId = new SAMLTrace.UniqueRequestId(request.requestId, request.method, request.url);
uniqueRequestId.create(id => {
uniqueRequestId.create(async id => {
let tracer = SAMLTrace.TraceWindow.instance();

// Maybe revise the HTTP method on redirected requests
Expand All @@ -775,7 +785,7 @@ SAMLTrace.TraceWindow.prototype = {
}

entry.headers = request.requestHeaders;
tracer.addRequestItem(entry, () => entry.res);
await tracer.addRequestItem(entry, () => entry.res);
tracer.updateStatusBar();
});
},
Expand Down
14 changes: 8 additions & 6 deletions src/SAMLTraceIO.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ SAMLTraceIO.prototype = {
* Imports requests and restores them in the TraceWindow.
**/
'importRequests': function(selectedFile, tracer, onSuccess, onError) {
const parseRequests = rawResult => {
const parseRequests = async rawResult => {
try {
let exportedSession = JSON.parse(rawResult);
let successfullyRestored = this.restoreFromImport(exportedSession.requests, tracer, onError);
let successfullyRestored = await this.restoreFromImport(exportedSession.requests, tracer, onError);
if (successfullyRestored) {
onSuccess();
}
Expand All @@ -73,7 +73,7 @@ SAMLTraceIO.prototype = {
reader.readAsText(selectedFile);
},

'restoreFromImport' : function(importedRequests, tracer, onError) {
'restoreFromImport' : async function(importedRequests, tracer, onError) {
if (!importedRequests || importedRequests.length === 0) {
onError("There aren't any requests to import...");
return false;
Expand Down Expand Up @@ -124,11 +124,13 @@ SAMLTraceIO.prototype = {
};

let restoreableRequests = importedRequests.map(ir => createRestoreableModel(ir));
restoreableRequests.forEach(rr => {
// Sequential rather than forEach(), because addRequestItem() is asynchronous and
// attachResponseToRequest() must not run until the request has been added.
for (const rr of restoreableRequests) {
tracer.saveNewRequest(rr);
tracer.addRequestItem(rr, rr.getResponse);
await tracer.addRequestItem(rr, rr.getResponse);
tracer.attachResponseToRequest(rr.getResponse());
});
}

return true;
}
Expand Down
1 change: 0 additions & 1 deletion src/TraceWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
</div>
</div>

<script type="text/javascript" src="../lib/pako_inflate.min.js"></script>
<script type="module" src="hljs-init.js"></script>
<script type="text/javascript" src="splitter.js"></script>
<script type="text/javascript" src="hash.js"></script>
Expand Down
Loading