Skip to content

Commit

Permalink
Implement blacklisting of specific files/folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole Helbling committed Jun 13, 2019
1 parent 490685b commit cdc1c1c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Some of them are described below:
- Password field names
- URL field names
- OTP Auth field names
- Regex for hiding items (tests the full path to the item)
- Adding Passwords
- The default length for generating passwords
- Whether or not to include special characters in generated passwords by default
Expand Down
3 changes: 3 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
"passff_prefs_otpauth_field_names_label": {
"message": "OTP Auth field names"
},
"passff_prefs_filter_path_regex_label": {
"message": "Regex for hiding items, one per line (tests full path)"
},
"passff_prefs_script_howto": {
"message": "See passff.py for changing the environment variables of pass."
},
Expand Down
3 changes: 3 additions & 0 deletions src/content/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ <h1>passff_prefs_headline</h1>
</p><p>
<label>passff_prefs_otpauth_field_names_label</label>
<input type="text" id="pref_otpauthFieldNames" value="" />
</p><p>
<label>passff_prefs_filter_path_regex_label</label>
<textarea id="pref_filterPathRegex"></textarea>
</p>
</fieldset>
</div>
Expand Down
7 changes: 6 additions & 1 deletion src/modules/pass.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ PassFF.Pass = (function () {
isMeta: null,
hasMeta: null,
fullKey: (curDepth === 0) ? key : curParent.fullKey + '/' + key,
isHidden: null,
children: []
};

Expand All @@ -404,6 +405,8 @@ PassFF.Pass = (function () {
}
});

var isHiddenRegex = new RegExp(PassFF.Preferences.filterPathRegex.join("|"), 'i');

allItems.slice().reverse().forEach(item => {
let siblings = rootItems;
if (item.parent !== null) {
Expand All @@ -419,6 +422,7 @@ PassFF.Pass = (function () {
|| isUrlField(item.key)
|| isOtpauthField(item.key));
item.hasFields = item.children.some(c => allItems[c].isField);
item.isHidden = isHiddenRegex.test(item.fullKey);
});

return [allItems, rootItems];
Expand Down Expand Up @@ -630,7 +634,8 @@ PassFF.Pass = (function () {
.map(i => getItemQuality(i, urlStr))
.filter(i => (i.quality >= 0))
.sort((i1,i2) => (i2.quality - i1.quality))
.map(i => i.item);
.map(i => i.item)
.filter(i => !i.isHidden);
log.debug(matchingItems.length, 'matches for', urlStr);
return matchingItems;
},
Expand Down
4 changes: 3 additions & 1 deletion src/modules/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ PassFF.Preferences = (function () {
showStatus : true,
tbMenuShortcut : '',
recognisedSuffixes : 'co.uk,org.uk,me.uk,co.jp,com.au',
filterPathRegex : 'notes\nattributes\nattachments',
};

var listParams = {
Expand All @@ -100,7 +101,8 @@ PassFF.Preferences = (function () {
'urlFieldNames' : ',',
'otpauthFieldNames' : ',',
'autoFillBlacklist' : ',',
'recognisedSuffixes' : ','
'recognisedSuffixes' : ',',
'filterPathRegex' : '\n',
};

var lowerCaseParams = [
Expand Down

0 comments on commit cdc1c1c

Please sign in to comment.