This file is indexed.

/usr/lib/logdata-anomaly-miner/aminer/parsing/MatchContext.py is in logdata-anomaly-miner 0.0.7-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import MatchElement

class MatchContext(object):
  """This class allows storage of data relevant during the matching
  process, e.g. the root node and the remaining unmatched data.
  Then searching for non-atomic matches, e.g. sequences, the context
  might be modified by model subelements, even if the main model
  element will not return a match. In that case, those non-atomic
  model elements have to care to restore the context before returning."""

  def __init__(self, matchData):
    """Create a MatchContext with the full unmatched string data.
    @param matchData the data that will be tested by the next
    model element."""
    self.matchData=matchData
    self.rootMatchElement=MatchElement.MatchElement('/', None, None, [])

  def update(self, matchString):
    """Update the match context by removing the given matched
    string data from the context data still to be matched. This
    method does not check, if the removed data is the same as
    the trailing match data for performance reasons. This is done
    only in the DebugMatchContext class."""
    self.matchData=self.matchData[len(matchString):]


class DebugMatchContext(MatchContext):
  """This class defines a slower MatchContext for debugging purposes."""

  def __init__(self, matchData):
    self.debugInfo=''
    self.lastMatchData=None
    self.shortestUnmatchedData=None
    super(DebugMatchContext, self).__init__(matchData)

  def update(self, matchString):
    """Update the context and store debugging information."""
    if self.lastMatchData!=self.matchData:
      self.lastMatchData=self.matchData
      self.debugInfo+='Starting match update on %s\n' % repr(self.matchData)
    if not(self.matchData.startswith(matchString)):
      self.debugInfo+='Current data %s does not start with %s\n' % (repr(self.matchData), repr(matchData))
      raise Exception('Illegal state')
    self.matchData=self.matchData[len(matchString):]
    self.lastMatchData=self.matchData
    if (self.shortestUnmatchedData==None) or (len(self.matchData)<len(self.shortestUnmatchedData)):
      self.shortestUnmatchedData=self.matchData
    self.debugInfo+='Removed %s, remaining %d bytes\n' % (repr(matchString), len(self.matchData))

  def getDebugInfo(self):
    """Get the current debugging information and reset it."""
    result=self.debugInfo
    self.debugInfo=''
    result+='Shortest unmatched data was %s\n' % repr(self.shortestUnmatchedData)
    return(result)

  def getshortestUnmatchedData(self):
    """Get shortest matchData found while updating the internal
    state. This is useful to find out where the parsing process
    has terminated."""
    return(self.shortestUnmatchedData)