Skip to content

Commit

Permalink
0.1.5 (#53)
Browse files Browse the repository at this point in the history
* wip

* remove unnecessary code in popout

* wrap up 1.1.5
  • Loading branch information
clarkio authored Apr 22, 2019
1 parent 0054359 commit fda2d3b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Azure Mask Changelog

## 1.1.5 (2019-04-22)
### Changed
- Name to "Az Mask" as "Azure Mask" was taken down due to trademark infringement ("Azure")
- Regex used to find sensitive data to the simplified version looking for text with a signature following the Subscription ID pattern

### Added
- Ability to hide tooltips/title attribute for masked elements using css `pointer-events: none;`

<a name="1.1.4"></a>

## 1.1.4 (2018-08-15)

_New Features_
### Added

- Add support for government portal URLs [#44](https://github.com/clarkio/azure-mask/pull/44)
Binary file added extension/1.1.5/az-mask-0.1.5.crx
Binary file not shown.
Binary file added extension/1.1.5/az-mask-1.1.5.zip
Binary file not shown.
49 changes: 39 additions & 10 deletions src/content-script/mask-process.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
const isMaskedKeyName = 'isMasked';
const maskEnabledClassName = 'az-mask-enabled';
const sensitiveDataRegex = /^\s*([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})|((([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))\s*$/;
const sensitiveDataRegex = /^([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})$/;
/* ** Original regex prior to 2019-04-18 **
* const sensitiveDataRegex = /^\s*([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})|((([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))\s*$/;
*
*/
const sensitiveDataClassName = 'azdev-sensitive';
const blurCss = 'filter: blur(10px);';
const blurCss = 'filter: blur(10px); pointer-events: none;';
const tagNamesToMatch = ['DIV']; // uppercase

// add CSS style to blur
const style = document.createElement('style');
style.appendChild(document.createTextNode(''));
document.head.appendChild(style);

style.sheet.insertRule(`.${maskEnabledClassName} .azdev-sensitive { ${blurCss} }`);
style.sheet.insertRule(`.${maskEnabledClassName} .fxs-avatarmenu-username { display: none }`); // hide name instead of blurring
style.sheet.insertRule(`.${maskEnabledClassName} input.azc-bg-light { ${blurCss} }`); // input boxes used for keys, connection strings, etc
style.sheet.insertRule(`.${maskEnabledClassName} a.fxs-topbar-reportbug { display:none; }`); // report a bug button (MS internal only)
style.sheet.insertRule(
`.${maskEnabledClassName} .azdev-sensitive { ${blurCss} }`
);
style.sheet.insertRule(
`.${maskEnabledClassName} .fxs-avatarmenu-username { display: none }`
); // hide name instead of blurring
style.sheet.insertRule(
`.${maskEnabledClassName} input.azc-bg-light { ${blurCss} }`
); // input boxes used for keys, connection strings, etc
style.sheet.insertRule(
`.${maskEnabledClassName} a.fxs-topbar-reportbug { display:none; }`
); // report a bug button (MS internal only)
style.sheet.insertRule(
`.${maskEnabledClassName} div.fxs-topbar-internal { display:none; }`
); // "Preview" element in top navigation bar (MS internal only)
style.sheet.insertRule(
`.${maskEnabledClassName} .fxs-mecontrol-flyout { ${blurCss} }`
); // user account menu

getStoredMaskedStatus(isMasked => {
isMasked ? document.body.classList.add(maskEnabledClassName) : document.body.classList.remove(maskEnabledClassName);
isMasked
? document.body.classList.add(maskEnabledClassName)
: document.body.classList.remove(maskEnabledClassName);
});

// add class to elements already on the screen
Expand All @@ -27,7 +47,11 @@ Array.from(document.querySelectorAll(tagNamesToMatch.join()))
// add class to elements that are added to DOM later
const observer = new MutationObserver(mutations => {
mutations
.filter(m => shouldCheckContent(m.target, m.type) && sensitiveDataRegex.test(m.target.textContent))
.filter(
m =>
shouldCheckContent(m.target, m.type) &&
sensitiveDataRegex.test(m.target.textContent.trim())
)
.forEach(m => {
const node = m.type === 'characterData' ? m.target.parentNode : m.target;
if (node.classList) {
Expand All @@ -44,15 +68,20 @@ const config = {
observer.observe(document.body, config);

function shouldCheckContent(target, mutationType) {
return mutationType === 'characterData' || (target && tagNamesToMatch.some(tn => tn === target.tagName));
return (
mutationType === 'characterData' ||
(target && tagNamesToMatch.some(tn => tn === target.tagName))
);
}

function getStoredMaskedStatus(callback) {
chrome.storage.local.get(isMaskedKeyName, items => {
const { isMasked } = items;
if (typeof isMasked !== 'boolean') {
// default to true
chrome.storage.local.set({ [isMaskedKeyName]: true }, () => callback(true));
chrome.storage.local.set({ [isMaskedKeyName]: true }, () =>
callback(true)
);
} else {
callback(isMasked);
}
Expand Down
9 changes: 5 additions & 4 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 2,
"name": "Azure Mask",
"version": "1.1.4",
"description": "Conceals sensitive Azure information found in the portal views",
"name": "Az Mask",
"version": "1.1.5",
"description": "Does it's best to find and conceal sensitive Azure information found in the portal views",
"icons": {
"16": "/icons/icon16.png",
"48": "/icons/icon48.png",
Expand All @@ -22,7 +22,8 @@
],
"js": ["/content-script/mask-process.js"],
"run_at": "document_idle",
"all_frames": true
"all_frames": true,
"match_about_blank": true
}
],
"permissions": [
Expand Down
12 changes: 5 additions & 7 deletions src/popout/popout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const sensitiveDataRegex = /^([a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})|((([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,})))$/;
const sensitiveDataClassName = 'azdev-sensitive';
let allMasksEnabled = true;

let allMasksCheckbox = document.getElementById('toggle-all-masks');
Expand All @@ -8,7 +6,7 @@ allMasksCheckbox.addEventListener('click', toggleAllMasks);
chrome.tabs.executeScript(
{
code: "document.body.classList.contains('az-mask-enabled');",
allFrames: false
allFrames: true
},
results => {
if (results) {
Expand Down Expand Up @@ -39,11 +37,11 @@ function injectDisableAllMasks() {
});
}

document.addEventListener('DOMContentLoaded', function () {
var y = document.getElementById("index_link");
y.addEventListener("click", openIndex);
document.addEventListener('DOMContentLoaded', function() {
var y = document.getElementById('index_link');
y.addEventListener('click', openIndex);
});

function openIndex() {
chrome.tabs.create({ active: true, url: "https://aka.ms/publicportal" });
chrome.tabs.create({ active: true, url: 'https://aka.ms/publicportal' });
}

0 comments on commit fda2d3b

Please sign in to comment.