This file is indexed.

/usr/lib/python3/dist-packages/authres/__init__.py is in python3-authres 0.602-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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# coding: utf-8

# Copyright © 2011-2013 Julian Mehnle <julian@mehnle.net>,
# Copyright © 2011-2013 Scott Kitterman <scott@kitterman.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Package for parsing ``Authentication-Results`` headers as defined in RFC 5451.
Optional support for authentication methods defined in RFCs 5617, 6008, and 6212.

Examples:
RFC 5451 B.2
>>> str(AuthenticationResultsHeader('test.example.org'))
'Authentication-Results: test.example.org; none'

RFC 5451 B.3
>>> str(AuthenticationResultsHeader(authserv_id = 'example.com',
... results = [SPFAuthenticationResult(result = 'pass',
... smtp_mailfrom = 'example.net')]))
'Authentication-Results: example.com; spf=pass smtp.mailfrom=example.net'

RFC 5451 B.4(1)
>>> str(AuthenticationResultsHeader(authserv_id = 'example.com',
... results = [SMTPAUTHAuthenticationResult(result = 'pass', result_comment = 'cram-md5',
... smtp_auth = 'sender@example.net'), SPFAuthenticationResult(result = 'pass',
... smtp_mailfrom = 'example.net')]))
'Authentication-Results: example.com; auth=pass (cram-md5) smtp.auth=sender@example.net; spf=pass smtp.mailfrom=example.net'

RFC 5451 B.4(2)
>>> str(AuthenticationResultsHeader(authserv_id = 'example.com',
... results = [SenderIDAuthenticationResult(result = 'pass',
... header_from = 'example.com')]))
'Authentication-Results: example.com; sender-id=pass header.from=example.com'

RFC 5451 B.5(1) # Note: RFC 5451 uses 'hardfail' instead of 'fail' for
SPF failures. Hardfail is deprecated.  See RFC 6577.
Examples here use the correct 'fail'. The authres module does not
validate result codes, so either will be processed.

>>> str(AuthenticationResultsHeader(authserv_id = 'example.com',
... results = [SenderIDAuthenticationResult(result = 'fail',
... header_from = 'example.com'), DKIMAuthenticationResult(result = 'pass',
... header_i = 'sender@example.com', result_comment = 'good signature')]))
'Authentication-Results: example.com; sender-id=fail header.from=example.com; dkim=pass (good signature) header.i=sender@example.com'

# Missing parsing header comment.
#FIXME
>>> arobj = AuthenticationResultsHeader.parse('Authentication-Results: example.com; sender-id=fail header.from=example.com; dkim=pass (good signature) header.i=sender@example.com')
>>> str(arobj.authserv_id)
'example.com'
>>> str(arobj.results[0])
'sender-id=fail header.from=example.com'
>>> str(arobj.results[0].method)
'sender-id'
>>> str(arobj.results[0].result)
'fail'
>>> str(arobj.results[0].header_from)
'example.com'
>>> str(arobj.results[0].properties[0].type)
'header'
>>> str(arobj.results[0].properties[0].name)
'from'
>>> str(arobj.results[0].properties[0].value)
'example.com'
>>> str(arobj.results[1])
'dkim=pass header.i=sender@example.com'
>>> str(arobj.results[1].method)
'dkim'
>>> str(arobj.results[1].result)
'pass'
>>> str(arobj.results[1].header_i)
'sender@example.com'
>>> str(arobj.results[1].properties[0].type)
'header'
>>> str(arobj.results[1].properties[0].name)
'i'
>>> str(arobj.results[1].properties[0].value)
'sender@example.com'
"""

MODULE = 'authres'

__author__  = 'Julian Mehnle, Scott Kitterman'
__email__   = 'julian@mehnle.net'
__version__ = '0.602'

import authres.core

# Backward compatibility: For the benefit of user modules referring to authres.…:
from authres.core import *

# FeatureContext class & convenience methods
###############################################################################

class FeatureContext(object):
    """
    Class representing a "feature context" for the ``authres`` package.
    A feature context is a collection of extension modules that may override
    the core AuthenticationResultsHeader class or result classes, or provide
    additional result classes for new authentication methods.

    To instantiate a feature context, import the desired ``authres.…`` extension
    modules and pass them to ``FeatureContext()``.

    A ``FeatureContext`` object provides ``parse``, ``parse_value``, ``header``,
    and ``result`` methods specific to the context's feature set.
    """

    def __init__(self, *modules):
        self.header_class                = authres.core.AuthenticationResultsHeader
        self.result_class_by_auth_method = {}

        modules = [authres.core] + list(modules)
        for module in modules:
            try:
                self.header_class = module.AuthenticationResultsHeader
            except AttributeError:
                # Module does not provide new AuthenticationResultsHeader class.
                pass

            try:
                for result_class in module.RESULT_CLASSES:
                    self.result_class_by_auth_method[result_class.METHOD] = result_class
            except AttributeError:
                # Module does not provide AuthenticationResult subclasses.
                pass

    def parse(self, string):
        return self.header_class.parse(self, string)

    def parse_value(self, string):
        return self.header_class.parse_value(self, string)

    def header(self,
        authserv_id = None,  authserv_id_comment = None,
        version     = None,  version_comment     = None,
        results     = None
    ):
        return self.header_class(
            self, authserv_id, authserv_id_comment, version, version_comment, results)

    def result(self, method, version = None,
        result = None, result_comment = None,
        reason = None, reason_comment = None,
        properties = None
    ):
        try:
            return self.result_class_by_auth_method[method](version,
                result, result_comment, reason, reason_comment, properties)
        except KeyError:
            return authres.core.AuthenticationResult(method, version,
                result, result_comment, reason, reason_comment, properties)

_core_features = None
def core_features():
    "Returns default feature context providing only RFC 5451 core features."
    global _core_features
    if not _core_features:
        _core_features = FeatureContext()
    return _core_features

_all_features = None
def all_features():
    """
    Returns default feature context providing all features shipped with the
    ``authres`` package.
    """
    global _all_features
    if not _all_features:
        import authres.dkim_b
        import authres.dkim_adsp
        import authres.vbr
        import authres.dmarc
        _all_features = FeatureContext(
            authres.dkim_b,
            authres.dkim_adsp,
            authres.vbr,
            authres.dmarc
        )
    return _all_features

# Simple API with implicit core-features-only context
###############################################################################

class AuthenticationResultsHeader(authres.core.AuthenticationResultsHeader):
    @classmethod
    def parse(self, string):
        return authres.core.AuthenticationResultsHeader.parse(core_features(), string)

    @classmethod
    def parse_value(self, string):
        return authres.core.AuthenticationResultsHeader.parse_value(core_features(), string)

    def __init__(self,
        authserv_id = None,  authserv_id_comment = None,
        version     = None,  version_comment     = None,
        results     = None
    ):
        authres.core.AuthenticationResultsHeader.__init__(self,
            core_features(), authserv_id, authserv_id_comment, version, version_comment, results)

def result(method, version = None,
    result = None, result_comment = None,
    reason = None, reason_comment = None,
    properties = None
):
    return core_features().result(method, version,
        result, result_comment, reason, reason_comment, properties)

def header(
    authserv_id = None,  authserv_id_comment = None,
    version     = None,  version_comment     = None,
    results     = None
):
    return core_features().header(
        authserv_id, authserv_id_comment, version, version_comment, results)

def parse(string):
    return core_features().parse(string)

def parse_value(string):
    return core_features().parse_value(string)

# vim:sw=4 sts=4