This file is indexed.

/usr/lib/python2.7/dist-packages/test_cracklib.py is in python-cracklib 2.9.2-5build1.

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
# -*- python -*-
# -*- coding: utf-8 -*-
"""
Test suite for cracklib's Python binding.
"""
import os
import sys
import unittest
import cracklib

__version__ = '2.8.19'

tests = []
dictpath = None


class TestModuleFunctions(unittest.TestCase):
    def test_FascistCheck(self):
        try:
            cracklib.FascistCheck('test', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            pass

    def test_VeryFascistCheck(self):
        try:
            cracklib.VeryFascistCheck('test', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            pass
        try:
            cracklib.VeryFascistCheck('LhIRI6JXpKhUqBjT', dictpath=dictpath)
        except ValueError:
            self.fail('password should be good enough')

    def test_palindrome(self):
        try:
            cracklib.VeryFascistCheck('ot23#xyx#32to', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            e = sys.exc_info()[1]
            self.assertEqual('is a palindrome', str(e))

    def test_same(self):
        try:
            cracklib.VeryFascistCheck('test', 'test', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            e = sys.exc_info()[1]
            self.assertEqual('is the same as the old one', str(e))

    def test_case_change(self):
        try:
            cracklib.VeryFascistCheck('test', 'TeSt', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            e = sys.exc_info()[1]
            self.assertEqual('case changes only', str(e))

    def test_similar(self):
        try:
            cracklib.VeryFascistCheck('test12', 'test34', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            e = sys.exc_info()[1]
            self.assertEqual('is too similar to the old one', str(e))

    def test_simple(self):
        try:
            cracklib.VeryFascistCheck('t3sx24', dictpath=dictpath)
            self.fail('expected ValueError')
        except ValueError:
            e = sys.exc_info()[1]
            self.assertEqual('is too simple', str(e))

    def test_simple_lower(self):
        for passwd in ['t' * i for i in range(
                cracklib.MIN_LENGTH - cracklib.LOW_CREDIT)]:
            self.assertEquals(
                1, cracklib.simple(passwd),
                'password {0} should be detected as too simple'.format(
                    passwd))
        self.assertEquals(0, cracklib.simple(
            't' * (cracklib.MIN_LENGTH - cracklib.LOW_CREDIT)))

    def test_simple_upper(self):
        for passwd in ['T' * i for i in range(
                cracklib.MIN_LENGTH - cracklib.UP_CREDIT)]:
            self.assertEquals(
                1, cracklib.simple(passwd),
                'password {0} should be detected as too simple'.format(
                    passwd))
        self.assertEquals(0, cracklib.simple(
            'T' * (cracklib.MIN_LENGTH - cracklib.UP_CREDIT)))

    def test_simple_digit(self):
        for passwd in ['1' * i for i in range(
                cracklib.MIN_LENGTH - cracklib.DIG_CREDIT)]:
            self.assertEquals(
                1, cracklib.simple(passwd),
                'password {0} should be detected as too simple'.format(
                    passwd))
        self.assertEquals(0, cracklib.simple(
            '1' * (cracklib.MIN_LENGTH - cracklib.DIG_CREDIT)))

    def test_simple_other(self):
        for passwd in ['#' * i for i in range(
                cracklib.MIN_LENGTH - cracklib.OTH_CREDIT)]:
            self.assertEquals(
                1, cracklib.simple(passwd),
                'password {0} should be detected as too simple'.format(
                    passwd))
        self.assertEquals(0, cracklib.simple(
            '#' * (cracklib.MIN_LENGTH - cracklib.OTH_CREDIT)))

    def test_simple_combinations(self):
        testset = '#a' * (cracklib.MIN_LENGTH // 2)
        for passwd in [testset[:i] for i in range(
                cracklib.MIN_LENGTH -
                cracklib.LOW_CREDIT -
                cracklib.OTH_CREDIT)]:
            self.assertEquals(
                1, cracklib.simple(passwd),
                'password {0} should be detected as too simple'.format(
                    passwd))
        self.assertEquals(0, cracklib.simple(
            testset[:(cracklib.MIN_LENGTH - cracklib.LOW_CREDIT -
                      cracklib.OTH_CREDIT)]))


tests.append(TestModuleFunctions)


def run(verbosity=1, repeat=1, use_dictpath=None):
    global dictpath
    print(('cracklib is installed in: ' + os.path.dirname(__file__)))
    print(('cracklib version: ' + __version__))
    print((sys.version))
    dictpath = use_dictpath

    suite = unittest.TestSuite()
    for cls in tests:
        for _ in range(repeat):
            suite.addTest(unittest.makeSuite(cls))
    runner = unittest.TextTestRunner(verbosity=verbosity)
    return runner.run(suite)