p0deje / Maccy

Lightweight clipboard manager for macOS
https://maccy.app
MIT License
12.02k stars 515 forks source link

Feature Request: Ignore based on text content? #540

Closed mmiller42 closed 10 months ago

mmiller42 commented 1 year ago

Since you have the ability to ignore entries by source application and pasteboard type, could you also add the ability to filter based on text content matching a pattern, such as a regular expression? Obviously these rules would only apply to textual content.

For example, a user might frequently copy a password to their clipboard from various sources, but they frequently screen share while working and don't want to accidentally display their password when opening up Maccy. They might want to pattern match on the first few characters of their password "PASSWORD" e.g. /^\s*PA.+$/. Or they might find themselves copying AWS access keys from the AWS web console to their clipboard frequently and want to ignore them without excluding all pasteboard events from their browser.

p0deje commented 1 year ago

Can you elaborate about what kind of regexps are you planning to use to exclude content? The example with PASSWORD/AWS won't likely work because those are unique so I'm not sure how useful this is going to be.

mmiller42 commented 1 year ago

Well what I mean is that it would be a user-configurable area like the way I can configure ignore source applications and pasteboard types:

Then a user could add regular expressions (or globs or whatever you prefer) to another section on this panel, "Text Patterns" or something.

So for example, as an individual user, I might want to add these to my ignore list:

Text Pattern Description
A(K\|S)IA[A-Z0-9]{16} match AKIA/ASIA followed by 16 uppercase letters and/or numbers, i.e. the format of an AWS access key ID
XX[A-Za-z0-9/+=]{38} AWS secret access keys are 40 characters long and contain alphanumerics, /, +, =. Unfortunately sha hashes such as those used in git also match this pattern. But I would not feel horrible about storing the first two characters of the key in order to add it to an ignore list. (So in this example my access key starts with XX)
XX[^\s]{30} Imagining I commonly copy a long password to my clipboard -- again, putting the first two characters in my ignore list, then simply excluding any string of a certain length and not containing whitespace
https:\/\/privnote\.com Some web services offer the ability to create private shareable content by URL -- ideally we could match and exclude URLs so I can copy/paste a URL from a particular website without it adding it to history. Say for example, I use a service to share a private password with coworker 1 via Slack. Before they open it, I accidentally expose the URL via screen share to coworker 2, who accesses it first.
p0deje commented 1 year ago

Thanks for a thorough explanation of this feature. It's quite easy to implement the actual logic, but building UI for adding/removing patterns as well as localizing it to all languages is a bit more tedious. I will merge PRs adding this, but for now don't have time to implement on my own.

Slackadays commented 1 year ago

If you have got to have this feature now, then there's also the similar CLI based CB that currently offers it in the nightly builds.

p0deje commented 1 year ago

@Slackadays You forgot shameless-self-promotion tag :)

That-Dude commented 1 year ago

I've developed an unhealthy dependancy on Maccy, but I also work in IT-sec and having a big list of passwords in my clipboard is a bit of an issue, this would be such a great addition.

p0deje commented 1 year ago

@That-Dude What are the patterns you'd want Maccy to ignore?

That-Dude commented 1 year ago

@That-Dude What are the patterns you'd want Maccy to ignore?

The regex above covers my use case, but being able to add my own patterns would be nice.

Given that this is an edge case, keeping the regex strings in a text file on disk would more than suffice, no need to develop a UI for it.

If development tome is no issue id say keep the passwords in the history for all apps but obscure them and prompt for a fingerprint when the user pastes them, but that seems like a lot of effort.

p0deje commented 1 year ago

I just wanted to confirm that you'd need several regexp patterns, not just one.

That-Dude commented 1 year ago

I just wanted to confirm that you'd need several regexp patterns, not just one.

Yeah, several regex strings for sure. I copy passwords and private keys to the clipboard a lot and the formats are varied but easily definable in regex.

PS Just wan't to re-iterate how much I appreciate Maccy in my daily life, I used Clippy previously but it had no M1 builds and the author is AWOL. Maccy is the ideal replacement and here's the author actually responding to my niche requests! Legend

p0deje commented 1 year ago

PS Just wan't to re-iterate how much I appreciate Maccy in my daily life, I used Clippy previously but it had no M1 builds and the author is AWOL. Maccy is the ideal replacement and here's the author actually responding to my niche requests! Legend

Thank you. I have to say that Maccy wouldn't be possible without all the hard work @Econa77 put into Clipy. I used to peek into its codebase to figure out various solutions and also Maccy uses packages that were written for Clipy heavily: (e.g. https://github.com/Clipy/Sauce for QWERTY-Dvorak keyboard layout mapping). Thank you, fabulous @Clipy folks!

andrewpeal commented 1 year ago

Hi @p0deje I'm happy to do the heavy lifting on this if it hasn't been assigned?

p0deje commented 1 year ago

@andrewpeal Sure, I would be happy to merge PR by adding this. Roughly, the implementation would require:

  1. Adding new ignoreRegexp (array of strings) to https://github.com/p0deje/Maccy/blob/master/Maccy/UserDefaults%2BConfiguration.swift.
  2. Adding new shouldIgnore() that will check the contents against the stored regexps https://github.com/p0deje/Maccy/blob/9d58afac7f6f77a83ae17c62ce361acd8c848465/Maccy/Clipboard.swift#L163-L174.
  3. Adding new UI to add/remove regexps in the Preferences window. This would also need to include localization in all languages.
mmiller42 commented 1 year ago

FWIW personally as a user I have no problem configuring this without UI if it's just a few simple terminal commands to defaults write or whatever

p0deje commented 1 year ago

I wouldn’t consider this feature complete if there is no UI for configuration. On Jul 16, 2023, at 14:58, Matt Miller @.***> wrote: FWIW personally as a user I have no problem configuring this without UI if it's just a few simple terminal commands to defaults write or whatever

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

andrewpeal commented 1 year ago

Leave it with me. I'll submit PR.

Kandamkolathy commented 11 months ago

Since this issue hasn't received any changes, I've gone ahead and made a PR with the changes. I hope that's okay.

p0deje commented 10 months ago

Implemented in #632