Skip to content

Commit

Permalink
Fix problems with Firefox 103+
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Bennetts <psiinon@gmail.com>
  • Loading branch information
psiinon committed Sep 22, 2022
1 parent ad0fdf7 commit 4f8a6c3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Update minimum ZAP version to 2.11.1.
- Depend on Network add-on for the tutorial server.
### Fixed
- Problems with Firefox 103+
- Spider status post 2.11.1

## [0.13.0] - 2021-10-06
### Changed
Expand Down
8 changes: 8 additions & 0 deletions src/main/zapHomeFiles/hud/target/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,45 +562,53 @@ const injection = (function () {

window.addEventListener('message', receiveMessages);

const sandbox = 'allow-storage-access-by-user-activation allow-scripts allow-same-origin allow-popups allow-forms allow-top-navigation';

const mframe = document.createElement('iframe');
mframe.id = MANAGEMENT;
mframe.src = ZAP_HUD_FILES + '/file/management.html?url=' + URL + '&frameId=management&tabId=' + tabId;
mframe.scrolling = 'no';
mframe.style = 'position: fixed; right: 0px; bottom: 50px; width:28px; height:60px; border: medium none; overflow: hidden; z-index: 2147483647;';
mframe.title = 'Management Area';
mframe.setAttribute('sandbox', sandbox);

const lframe = document.createElement('iframe');
lframe.id = LEFT_PANEL;
lframe.src = ZAP_HUD_FILES + '/file/panel.html?url=' + URL + '&orientation=left&frameId=leftPanel&tabId=' + tabId;
lframe.scrolling = 'no';
lframe.style = 'position: fixed; border: medium none; top: 30%; border: medium none; left: 0px; width: 110px; height: 300px; z-index: 2147483646;';
lframe.title = 'Left Panel';
lframe.setAttribute('sandbox', sandbox);

const rframe = document.createElement('iframe');
rframe.id = RIGHT_PANEL;
rframe.src = ZAP_HUD_FILES + '/file/panel.html?url=' + URL + '&orientation=right&frameId=rightPanel&tabId=' + tabId;
rframe.scrolling = 'no';
rframe.style = 'position: fixed; border: medium none; top: 30%; overflow: hidden; right: 0px; width: 110px; height: 300px; z-index: 2147483646;';
rframe.title = 'Right Panel';
rframe.setAttribute('sandbox', sandbox);

const bframe = document.createElement('iframe');
bframe.id = BOTTOM_DRAWER;
bframe.src = ZAP_HUD_FILES + '/file/drawer.html?url=' + URL + '&frameId=drawer&tabId=' + tabId;
bframe.scrolling = 'no';
bframe.style = 'position: fixed; border: medium none; overflow: hidden; left: 0px; bottom: 0px; width: 100%; height: 50px; z-index: 2147483646;';
bframe.title = 'Bottom Drawer';
bframe.setAttribute('sandbox', sandbox);

const dframe = document.createElement('iframe');
dframe.id = MAIN_DISPLAY;
dframe.src = ZAP_HUD_FILES + '/file/display.html?url=' + URL + '&frameId=display&tabId=' + tabId;
dframe.style = 'position: fixed; right: 0px; top: 0px; width: 100%; height: 100%; border: 0px none; display: none; z-index: 2147483647;';
dframe.title = 'Main Display';
dframe.setAttribute('sandbox', sandbox);

const gframe = document.createElement('iframe');
gframe.id = GROWLER_ALERTS;
gframe.src = ZAP_HUD_FILES + '/file/growlerAlerts.html?url=' + URL + '&frameId=growlerAlerts&tabId=' + tabId;
gframe.style = 'position: fixed; right: 0px; bottom: 30px; width: 500px; height: 0px;border: 0px none; z-index: 2147483647;';
gframe.title = 'Growler Alerts';
gframe.setAttribute('sandbox', sandbox);

document.body.append(mframe);
document.body.append(lframe);
Expand Down
28 changes: 19 additions & 9 deletions src/main/zapHomeFiles/hud/tools/spider.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,24 @@ const Spider = (function () {
.catch(utils.errorHandler);
}

function spiderStatusHandler(event) {
const eventType = event.detail['event.type'];
utils.log(LOG_DEBUG, 'SpiderEventPublisher eventListener', 'Received ' + eventType + ' event');
if (eventType === 'scan.started') {
updateProgress('0%');
} else if (eventType === 'scan.progress') {
updateProgress(event.detail.scanProgress + '%');
} else if (eventType === 'scan.stopped' || eventType === 'scan.completed') {
spiderStopped();
}
}

self.addEventListener('activate', event => {
initializeStorage();
// Events up to 2.11.1
registerForZapEvents('org.zaproxy.zap.extension.spider.SpiderEventPublisher');
// Events post 2.11.1
registerForZapEvents('org.zaproxy.addon.spider.SpiderEventPublisher');
});

self.addEventListener('message', event => {
Expand Down Expand Up @@ -228,15 +243,10 @@ const Spider = (function () {
});

self.addEventListener('org.zaproxy.zap.extension.spider.SpiderEventPublisher', event => {
const eventType = event.detail['event.type'];
utils.log(LOG_DEBUG, 'SpiderEventPublisher eventListener', 'Received ' + eventType + ' event');
if (eventType === 'scan.started') {
updateProgress('0%');
} else if (eventType === 'scan.progress') {
updateProgress(event.detail.scanProgress + '%');
} else if (eventType === 'scan.stopped' || eventType === 'scan.completed') {
spiderStopped();
}
spiderStatusHandler(event);
});
self.addEventListener('org.zaproxy.addon.spider.SpiderEventPublisher', event => {
spiderStatusHandler(event);
});

return {
Expand Down

0 comments on commit 4f8a6c3

Please sign in to comment.