question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parsing of receiveds doesn't support via or id

See original GitHub issue

for example:

Received: from XXX.namprd06.prod.outlook.com (2603:10b6:207:3d::31) by XXX.namprd06.prod.outlook.com with HTTPS id 12345 via XXX.NAMPRD02.PROD.OUTLOOK.COM; Mon, 1 Oct 2018 09:49:22 +0000

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dfeinzeigcommented, Oct 26, 2018

@fedelemantuano , i’m thinking something along the lines of

import re
import exceptions
RECEIVED_PATTERNS = [
    r'(?:from\s+(?P<from>.+?)(?:\s+by|\s+with|\s+id|\s+for|\s+via|;))',
    r'(?:by\s+(?P<by>.+?)(?:\s+from|\s+with|\s+id|\s+for|\s+via|;))',
    r'(?:with\s+(?P<with>.+?)(?:\s+from|\s+by|\s+id|\s+for|\s+via|;))',
    r'(?:id\s+(?P<id>.+?)(?:\s+from|\s+by|\s+with|\s+for|\s+via|;))',
    r'(?:for\s+(?P<for>.+?)(?:\s+from|\s+by|\s+with|\s+id|\s+via|;))',
    r'(?:via\s+(?P<via>.+?)(?:\s+from|\s+by|\s+id|\s+for|\s+with|;))',
    r';\s*(?P<datetime>.*)'
]
RECEIVED_PATTERNS_COMPILED = [re.compile(pattern, re.IGNORECASE|re.DOTALL) for pattern in RECEIVED_PATTERNS]
def parse_received(received):
    values_by_clause = {}
    for pattern in RECEIVED_PATTERNS_COMPILED:
        matches = [match for match in pattern.finditer(received)]
        if len(matches) == 0:
            # no matches for this clause, but it's ok! keep going!
            continue
        elif len(matches) > 1:
            # uh, can't have more than one of each clause in a received.
            # so either there's more than one or the current regex is wrong
            raise exceptions.ValueError("More than one match found for %s in %s" % (pattern.pattern, received))
        else:
            # otherwise we have one matching clause!
            match = matches[0].groupdict()
            values_by_clause[match.keys()[0]] = match.values()[0]
    return values_by_clause

I realize that’s incomplete so far, but seems like it’ll be easier to maintain the regexes since each one is only responsible for matching a single clause.

0reactions
fedelemantuanocommented, Aug 9, 2020

No, I didn’t have time for this issue. But I will watch it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with my receiver determination | SAP Community
My scenario has an extended receiver determination at the ID. The receiver is determined by using the Receivers message type provided by SAP ......
Read more >
SIEM Receiver is parsing slowly or is behind in processing
Problem. SIEM Receiver has a backlog of unparsed data. For example, the Receiver might be hours behind in processing. The UI displays a...
Read more >
Configure the Ops Agent - Monitoring - Google Cloud
Each receiver must have an identifier, RECEIVER_ID , and include a type element. The valid types are: files : Collect logs by tailing...
Read more >
opentelemetry-collector-contrib/CHANGELOG.md at main
This is a breaking change, and as such will generate a startup error if the exporter is configured to send to an endpoint...
Read more >
Not receiving Parse Push Notifications In Android
Generally, I recommend the official tutorial. Your com.parse.ParseBroadcastReceiver uses wrong action names and should read: <receiver ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found