friedPotat0 / Spam-Scores

Thunderbird add-on to display spam scores according to mail headers. Supports spam/ham score headers of Rspamd and SpamAssassin. The add-on adds a column with the overall spam score to the mail list view and shows details of any matched spam/ham rule.
https://addons.thunderbird.net/de/thunderbird/addon/spam-scores/
Other
42 stars 6 forks source link

Retrieving headers as array #38

Closed dlh2 closed 2 years ago

dlh2 commented 2 years ago

Well this is the deal:

As said in #7 if there's priority, first we need to read the different spam headers, in the previous code, we achieve it by analizing the rawHeader as one string and we needed to separate each one, so for making it easier, Thunderbird has a way to get it separated so I'll take this approach by using getFull()

With this commit now is easier to put priority as we can make an object with the different priorities and we can even customize it.

As said in #8 and #32 the implementation for different scores should be interpolated to a way we can adapt it to the current scores, and it's easier to deal if we make a class or objects to the way we have it right now

Now I'll deal with #34 as it's probably a RegEx issue, and I'll need more email examples.

dlh2 commented 2 years ago

TODO: We need to do it in popup.js too, but I'll first fix 34.

I will check how to avoid the parsing the content preview part of the X-Spam-Report header. Otherwise, it will always be possible to send a mail with content falsely recognised as a spam rule.

Okay I should have seen this comment, then for making it easier to deal with this problem I'll have retrieve the headers as array.

dlh2 commented 2 years ago

image

Okay #34 problem is here, we have a lot of ways to deal with it, but you know, we can't split with \n as somehow the email is translated to some whitespaces therefore this gotta be interesting.

dlh2 commented 2 years ago

Note: I broke the spam score, don't pull it for now. (I'll do it tomorrow)

friedPotat0 commented 2 years ago

Don't worry. I'm not merging anything before looking through the code and testing the branch with the example mails in the test folder of this repo.

Your changes look promising so far. The getFull method of the message API is definitely the way to go.

dlh2 commented 2 years ago

@friedPotat0 mind if you fix this part?

image

This part is for experiments optimization, and for now I don't want to understand it until I go to transform it.

With this #34 is finished, but I saw sometimes the parser won't get some rules.

dlh2 commented 2 years ago

Okay, there's two issues with the new code.

First, we can't properly test, I don't know if the test Emails are real, but is really strange that Thunderbird detects mail-header values as a header. So we need to give real emails (removing content or sensitive data) to the tests.

image

Second, for the popup part we were using the SPAM_HEADER_REGEX which analizes all the rawHeader, we're transitioning to analizing by each header so the function we use right now

image

We might need to transform it to an array for getting saving various parts (which i'm on it right now)

dlh2 commented 2 years ago

Well, that's all, for this branch.

friedPotat0 commented 2 years ago

@friedPotat0 mind if you fix this part?

image

This part is for experiments optimization, and for now I don't want to understand it until I go to transform it.

With this #34 is finished, but I saw sometimes the parser won't get some rules.

I'll have a look at the problem over the weekend. Thanks again for all the optimisations!

dlh2 commented 2 years ago

I'm looking that we're using somewhat archived things as most of the ChromeUtils.Import are from xpCOM services, which are supposed to be removed https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/57#changes_for_add-on_and_mozilla_developers

Insert Scientist Dog Meme [I have no idea how that works]

If you know how can I debug experiments.js I would be gladly try to transform it to WebExtension.

friedPotat0 commented 2 years ago

The only way I could debug the experiments.js file so far is to use Services.console.logStringMessage('debug message') as a simple console logger.

When creating this add-on in the first place, I mostly tried to find other add-ons using MailExtensions on GitHub. Sadly there were not that many out there at this time. The documentation of these extensions is sometimes also not very easy to understand, as it is maintained across several web pages. This is the main reason why so many things are not as they probably should be 😉.

dlh2 commented 2 years ago

The only way I could debug the experiments.js file so far is to use Services.console.logStringMessage('debug message') as a simple console logger.

When creating this add-on in the first place, I mostly tried to find other add-ons using MailExtensions on GitHub. Sadly there were not that many out there at this time. The documentation of these extensions is sometimes also not very easy to understand, as it is maintained across several web pages. This is the main reason why so many things are not as they probably should be 😉.

Yeah it's something somewhat deprecated on Firefox 57 and we're on 91.

Atm, I'm going to change Services.pref -> browser.storage.local

What I do to understand is going to https://contest-server.cs.uchicago.edu/ref/JavaScript/developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Services.html

Then I use https://web.archive.org/ to understand what it does.

The only way I could debug the experiments.js file so far is to use Services.console.logStringMessage('debug message') as a simple console logger.

Can you show me where do you see it while debugging Mozilla Thunderbird? I can't see it.

friedPotat0 commented 2 years ago

What I do to understand is going to https://contest-server.cs.uchicago.edu/ref/JavaScript/developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Services.html

Then I use https://web.archive.org/ to understand what it does.

😂😂

Can you show me where do you see it while debugging Mozilla Thunderbird? I can't see it.

Nevermind, I just tested the logging and it seems like it is not working anymore in Thunderbird 91. Even the "Spam Scores startup completed" message is not displayed in the console. I don't have an older version of Thunderbird installed at the moment to test it there.

dlh2 commented 2 years ago

Then as Mozilla said, we're also transitioning from XPCom -> WebExtension