MetPX / sarracenia

https://MetPX.github.io/sarracenia
GNU General Public License v2.0
45 stars 22 forks source link

sundew extension is not considered when matching a pattern #374

Closed habilinour closed 3 years ago

habilinour commented 3 years ago

The code adds the sundew extension to the url but the matching is done against the old url instead of the new one

      # Adjust url to account for sundew extension if present, and files do not already include the names.
       if urllib.parse.urlparse(self.msg.urlstr).path.count(":") < 1 and 'sundew_extension' in self.msg.headers.keys() :
          urlstr=self.msg.urlstr + ':' + self.msg.headers[ 'sundew_extension' ]
       else:
          urlstr=self.msg.urlstr

       self.logger.debug("sr_consumer, path being matched: %s " % ( urlstr )  )

       if not self.parent.isMatchingPattern(self.msg.urlstr,self.accept_unmatch) :
          self.logger.debug("Rejected by accept/reject options")
          return False,self.msg

To consider the sundew extension when evaluating a pattern, the "if statement" should be changed to:

            if not self.parent.isMatchingPattern(urlstr,self.accept_unmatch) :
petersilva commented 3 years ago

can you do a git clone, and make a duff & pull request? It is not trivial to identify the specific lines... there are 7 occurrences of isMatchingPattern in the main code... Once that happens, I can run the flow tests.

petersilva commented 3 years ago

So there are seven occurrences of isMatchingPattern, and four occurrences of "Rejected by"... Naturally, it was the last one I looked at... On the other hand, that turned out to be good, because in all the other occurrences, it was already using urlstr, so it is pretty clear that it was a typo in sr_consumer.py. Found it! ran the flow_test... seems to work.

petersilva commented 3 years ago

fixed by previous patch for v2... still need to port it forward to v3

petersilva commented 3 years ago

This changes how every file is parsed by accept/reject clauses... so if you have existing configurations with

those accepts will no longer match, because the value of the sundew_extension attribute is appended to the URL to be matched.

one can fix by appending .* to the end... but need to review all occurrences.