Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (2)
Fix print statements for Python 3.6 compatibility
· dbfa93c6
Brian May
authored
Jul 15, 2018
dbfa93c6
Merge branch 'bam/security-tracker-update_python_print'
· a65236bb
Salvatore Bonaccorso
authored
Aug 18, 2018
a65236bb
Show whitespace changes
Inline
Side-by-side
bin/apt-update-file
View file @
a65236bb
#!/usr/bin/python
# This script is mainly used to demo the updateFile function.
from
__future__
import
print_function
import
os
import
os.path
import
string
...
...
@@ -28,7 +29,7 @@ if len(sys.argv) != 3:
try
:
debian_support
.
updateFile
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
except
:
print
>>
sys
.
stderr
,
\
"
error: in download of %s to %s:
"
%
(
repr
(
sys
.
argv
[
1
]),
repr
(
sys
.
argv
[
2
])
)
print
(
"
error: in download of %s to %s:
"
%
(
repr
(
sys
.
argv
[
1
]),
repr
(
sys
.
argv
[
2
])
)
,
file
=
sys
.
stderr
)
raise
bin/check-syntax
View file @
a65236bb
...
...
@@ -75,7 +75,7 @@ def parse_file(name, filename):
if
len
(
sys
.
argv
)
==
2
and
sys
.
argv
[
1
]
==
"
--get
"
:
l
=
[
src
[
"
name
"
]
for
src
in
sources
]
print
'
'
.
join
(
l
)
print
(
'
'
.
join
(
l
)
)
sys
.
exit
(
0
)
if
len
(
sys
.
argv
)
!=
3
or
find_source
(
sys
.
argv
[
1
])
==
None
:
...
...
bin/list-queue
View file @
a65236bb
...
...
@@ -224,5 +224,5 @@ def main():
"
version
"
:
1
,
"
binary
"
:
pkgwithdist
(
debs
,
dists
),
}
print
json
.
dumps
(
result
)
print
(
json
.
dumps
(
result
)
)
main
()
bin/mass-bug-filer
View file @
a65236bb
#!/usr/bin/python
from
__future__
import
print_function
import
sys
import
apt
...
...
@@ -7,7 +8,7 @@ import os
import
re
if
len
(
sys
.
argv
)
<
3
:
print
>>
sys
.
stderr
,
"
usage: %s FILE PACKAGE...
"
%
sys
.
argv
[
0
]
print
(
"
usage: %s FILE PACKAGE...
"
%
sys
.
argv
[
0
]
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
message_file
=
file
(
sys
.
argv
[
1
])
...
...
@@ -17,7 +18,7 @@ cache = apt.Cache()
errors
=
False
for
p
in
packages
:
if
not
cache
.
has_key
(
p
):
print
>>
sys
.
stderr
,
"
error: no such package:
"
,
p
print
(
"
error: no such package:
"
,
p
,
file
=
sys
.
stderr
)
errors
=
True
if
errors
:
sys
.
exit
(
2
)
...
...
@@ -37,7 +38,7 @@ for line in source_lines:
if
line
==
'
\n
'
:
if
h_subject
is
None
:
print
>>
sys
.
stderr
,
"
error: missing Subject header
"
print
(
"
error: missing Subject header
"
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
state
=
1
continue
...
...
@@ -45,7 +46,7 @@ for line in source_lines:
# state == 0
match
=
re_header
.
match
(
line
)
if
match
is
None
:
print
>>
sys
.
stderr
,
"
error: invalid line:
"
,
line
print
(
"
error: invalid line:
"
,
line
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
(
k
,
v
)
=
match
.
groups
()
if
k
==
"
Subject
"
:
...
...
@@ -54,7 +55,7 @@ for line in source_lines:
if
h_bug
.
has_key
(
k
):
h_bug
[
k
]
=
v
continue
print
>>
sys
.
stderr
,
"
error: invalid header field:
"
,
k
print
(
"
error: invalid header field:
"
,
k
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
def
make_message
(
pkg
):
...
...
@@ -79,7 +80,7 @@ for p in packages:
sendmail
(
make_message
(
p
))
for
p
in
packages
:
print
"
\t
- %s <unfixed> (bug filed)
"
%
p
print
(
"
\t
- %s <unfixed> (bug filed)
"
%
p
)
bin/show-debsecan
View file @
a65236bb
...
...
@@ -7,7 +7,7 @@ import zlib
from
cStringIO
import
StringIO
if
len
(
sys
.
argv
)
not
in
(
2
,
3
):
print
"
usage: show-debsecan DATABASE-PATH [BLOB-NAME]
"
print
(
"
usage: show-debsecan DATABASE-PATH [BLOB-NAME]
"
)
sys
.
exit
(
1
)
db
=
apsw
.
Connection
(
sys
.
argv
[
1
])
...
...
@@ -15,7 +15,7 @@ c = db.cursor()
if
len
(
sys
.
argv
)
==
2
:
for
(
name
,)
in
c
.
execute
(
"
SELECT name FROM debsecan_data ORDER BY name
"
):
print
name
print
(
name
)
else
:
# len(sys.argv) == 3
name
=
sys
.
argv
[
2
]
for
(
data
,)
in
c
.
execute
(
"
SELECT data FROM debsecan_data WHERE name = ?
"
,
...
...
@@ -47,9 +47,9 @@ else: # len(sys.argv) == 3
break
(
package
,
vuln
,
rest
)
=
line
.
split
(
'
,
'
,
2
)
vuln
=
vuln_names
[
int
(
vuln
)]
print
"
%s,%s,%s
"
%
(
package
,
vuln
,
rest
)
print
(
"
%s,%s,%s
"
%
(
package
,
vuln
,
rest
)
)
for
line
in
data
:
print
line
,
print
(
line
)
db
.
close
()
bin/src2bin_text.py
View file @
a65236bb
...
...
@@ -68,4 +68,4 @@ if __name__ == '__main__':
for
line
in
fileinput
.
input
():
if
'
We recommend that you upgrade your
'
in
line
:
line
=
word_wrap
(
"
%s: %s.
\n
"
%
(
line
[:
-
2
],
change
(
line
,
exclude
)),
width
=
73
)
print
line
,
print
(
line
)
bin/tracker_service.py
View file @
a65236bb
...
...
@@ -12,8 +12,8 @@ import email.utils
if
__name__
==
"
__main__
"
:
if
len
(
sys
.
argv
)
not
in
(
3
,
5
):
print
"
usage: python tracker_service.py SOCKET-PATH DATABASE-PATH
"
print
"
python tracker_service.py URL HOST PORT DATABASE-PATH
"
print
(
"
usage: python tracker_service.py SOCKET-PATH DATABASE-PATH
"
)
print
(
"
python tracker_service.py URL HOST PORT DATABASE-PATH
"
)
sys
.
exit
(
1
)
if
len
(
sys
.
argv
)
==
3
:
socket_name
=
sys
.
argv
[
1
]
...
...
bin/update-db
View file @
a65236bb
#!/usr/bin/python
from
__future__
import
print_function
import
os
import
os.path
...
...
@@ -40,20 +41,20 @@ try:
warnings
=
db
.
readBugs
(
cursor
,
'
data
'
)
except
SyntaxError
as
e
:
if
e
.
filename
is
None
or
e
.
lineno
is
None
:
print
"
error:
"
,
e
print
(
"
error:
"
,
e
)
else
:
print
"
%s:%d: %s
"
%
(
e
.
filename
,
e
.
lineno
,
e
.
msg
)
print
(
"
%s:%d: %s
"
%
(
e
.
filename
,
e
.
lineno
,
e
.
msg
)
)
sys
.
exit
(
1
)
except
debian_support
.
ParseError
as
e
:
e
.
printOut
(
sys
.
stderr
)
sys
.
exit
(
1
)
except
security_db
.
InsertError
as
e
:
for
err
in
e
.
errors
:
print
err
print
(
err
)
sys
.
exit
(
1
)
if
warnings
:
for
x
in
warnings
:
print
x
print
(
x
)
sys
.
exit
(
1
)
# Packages
...
...
@@ -73,7 +74,7 @@ if new_file:
warnings
=
db
.
calculateVulnerabilities
(
cursor
)
if
warnings
:
for
x
in
warnings
:
print
x
print
(
x
)
sys
.
exit
(
1
)
# debsecan data
...
...
lib/python/debian_support.py
View file @
a65236bb
...
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from
__future__
import
print_function
"""
This module implements facilities to deal with Debian-specific metadata.
"""
...
...
@@ -320,7 +321,7 @@ def updateFile(remote, local, verbose=None):
local_file
=
file
(
local
)
except
IOError
:
if
verbose
:
print
"
updateFile: no local copy, downloading full file
"
print
(
"
updateFile: no local copy, downloading full file
"
)
return
downloadFile
(
remote
,
local
)
lines
=
local_file
.
readlines
()
...
...
@@ -338,11 +339,11 @@ def updateFile(remote, local, verbose=None):
index_fields
=
list
(
PackageFile
(
index_name
,
index_url
))
except
ParseError
:
if
verbose
:
print
"
updateFile: could not interpret patch index file
"
print
(
"
updateFile: could not interpret patch index file
"
)
return
downloadFile
(
remote
,
local
)
except
IOError
:
if
verbose
:
print
"
updateFile: could not download patch index file
"
print
(
"
updateFile: could not download patch index file
"
)
return
downloadFile
(
remote
,
local
)
for
fields
in
index_fields
:
...
...
@@ -351,7 +352,7 @@ def updateFile(remote, local, verbose=None):
(
remote_hash
,
remote_size
)
=
re_whitespace
.
split
(
value
)
if
local_hash
==
remote_hash
:
if
verbose
:
print
"
updateFile: local file is up-to-date
"
print
(
"
updateFile: local file is up-to-date
"
)
return
lines
continue
...
...
@@ -379,16 +380,16 @@ def updateFile(remote, local, verbose=None):
continue
if
verbose
:
print
"
updateFile: field %s ignored
"
%
`
field
`
print
(
"
updateFile: field %s ignored
"
%
repr
(
field
))
if
not
patches_to_apply
:
if
verbose
:
print
"
updateFile: could not find historic entry
"
,
local_hash
print
(
"
updateFile: could not find historic entry
"
,
local_hash
)
return
downloadFile
(
remote
,
local
)
for
patch_name
in
patches_to_apply
:
if
verbose
:
print
"
updateFile: downloading patch
"
+
`
patch_name
`
print
(
"
updateFile: downloading patch
"
+
repr
(
patch_name
))
try
:
patch_contents
=
downloadGunzipLines
(
remote
+
'
.diff/
'
+
patch_name
+
'
.gz
'
)
...
...
@@ -396,15 +397,15 @@ def updateFile(remote, local, verbose=None):
return
downloadFile
(
remote
,
local
)
if
readLinesSHA1
(
patch_contents
)
!=
patch_hashes
[
patch_name
]:
if
verbose
:
print
"
updateFile: patch was garbled:
"
+
repr
(
patch_name
)
print
(
"
updateFile: patch was garbled:
"
+
repr
(
patch_name
)
)
return
downloadFile
(
remote
,
local
)
patchLines
(
lines
,
patchesFromEdScript
(
patch_contents
))
new_hash
=
readLinesSHA1
(
lines
)
if
new_hash
!=
remote_hash
:
if
verbose
:
print
"
updateFile: patch failed, got %s instead of %s
"
\
%
(
new_hash
,
remote_hash
)
print
(
"
updateFile: patch failed, got %s instead of %s
"
%
(
new_hash
,
remote_hash
)
)
return
downloadFile
(
remote
,
local
)
replaceFile
(
lines
,
local
)
...
...
lib/python/secmaster.py
View file @
a65236bb
...
...
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from
__future__
import
print_function
# Name of the security-master host
HOST
=
"
seger.debian.org
"
...
...
@@ -55,4 +56,4 @@ def listqueue():
if
__name__
==
"
__main__
"
:
for
pkg
,
archs
in
listqueue
():
print
"
"
.
join
(
pkg
.
astuple
()),
"
=>
"
,
"
,
"
.
join
(
archs
)
print
(
"
"
.
join
(
pkg
.
astuple
()),
"
=>
"
,
"
,
"
.
join
(
archs
)
)
lib/python/sectracker/repo.py
View file @
a65236bb
...
...
@@ -251,7 +251,7 @@ class RepoCollection(object):
def
warn
(
self
,
msg
):
if
self
.
verbose
:
print
msg
print
(
msg
)
class
Config
(
object
):
def
__init__
(
self
,
config
,
root
):
...
...
lib/python/sectracker/xcollections.py
View file @
a65236bb
...
...
@@ -72,7 +72,7 @@ def namedtuple(typename, field_names, verbose=False):
for
i
,
name
in
enumerate
(
field_names
):
template
+=
'
%s = _property(_itemgetter(%d))
\n
'
%
(
name
,
i
)
if
verbose
:
print
template
print
(
template
)
# Execute the template string in a temporary namespace and
# support tracing utilities by setting a value for frame.f_globals['__name__']
...
...
lib/python/sectracker_test/run.py
View file @
a65236bb
...
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from
__future__
import
print_function
if
__name__
!=
"
__main__
"
:
raise
Exception
(
"
run must be executed directly
"
)
...
...
@@ -45,13 +46,13 @@ for name in files:
if
name
[
-
3
:]
!=
"
.py
"
or
name
==
"
run.py
"
:
continue
fullpath
=
"
%s/%s
"
%
(
ourpath
,
name
)
print
"
* Running
"
,
name
print
(
"
* Running
"
,
name
)
p
=
subprocess
.
Popen
((
"
python
"
,
"
--
"
,
fullpath
),
env
=
env
)
ret
=
p
.
wait
()
if
ret
!=
0
:
print
"
Test exited with status
"
,
ret
print
print
(
"
Test exited with status
"
,
ret
)
print
()
errors
=
errors
or
ret
!=
0
if
errors
:
print
"
ERROR: some tests aborted with errors
"
print
(
"
ERROR: some tests aborted with errors
"
)
sys
.
exit
(
1
)
lib/python/sectracker_test/test_analyzers.py
View file @
a65236bb
...
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from
__future__
import
print_function
import
os
...
...
@@ -43,7 +44,7 @@ if False:
for
r
,
pv
in
rpv
.
items
():
for
p
,
v
in
pv
.
items
():
if
len
(
v
)
>
1
:
print
r
,
p
,
v
print
(
r
,
p
,
v
)
# copysources
copysrc
=
copysources
(
bugdb
,
diag
)
...
...
@@ -54,12 +55,12 @@ assert "DSA-1472-1" in copysrc["CVE-2008-0225"]
vdb
=
fixedversions
(
bugdb
,
copysrc
,
rpv
,
diag
)
if
False
:
for
v
in
vdb
:
print
v
print
(
v
)
assert
bestversion
(
c
,
"
sid
"
,
"
bash
"
).
name
==
"
bash
"
assert
bestversion
(
c
,
"
sid
"
,
"
bash
"
,
(
"
unsupported
"
,
"
supported
"
)).
name
\
==
"
bash
"
for
err
in
diag
.
messages
():
print
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
print
(
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
)
assert
not
diag
.
messages
()
lib/python/sectracker_test/test_parsers.py
View file @
a65236bb
...
...
@@ -28,22 +28,22 @@ assert "bash" in o["bash"].binary
safeunlink
(
"
../../data/CVE/list
"
+
EXTENSION
)
o
=
cvelist
(
"
../../data/CVE/list
"
)
for
err
in
o
.
messages
:
print
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
print
(
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
)
safeunlink
(
"
../../data/DSA/list
"
+
EXTENSION
)
o
=
dsalist
(
"
../../data/DSA/list
"
)
for
err
in
o
.
messages
:
print
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
print
(
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
)
safeunlink
(
"
../../data/DTSA/list
"
+
EXTENSION
)
o
=
dtsalist
(
"
../../data/DTSA/list
"
)
for
err
in
o
.
messages
:
print
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
print
(
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
)
safeunlink
(
"
../../data/DLA/list
"
+
EXTENSION
)
o
=
dlalist
(
"
../../data/DLA/list
"
)
for
err
in
o
.
messages
:
print
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
print
(
"
%s:%d: %s: %s
"
%
(
err
.
file
,
err
.
line
,
err
.
level
,
err
.
message
)
)
Message
=
sectracker
.
diagnostics
.
Message
for
(
line
,
res
,
xmsgs
)
in
[
...
...
lib/python/security_db.py
View file @
a65236bb
...
...
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from
__future__
import
print_function
"""
This module implements a small database for tracking security bugs.
...
...
@@ -268,8 +269,8 @@ class DB:
c
.
execute
(
"
PRAGMA user_version = 22
"
)
elif
v
!=
self
.
schema_version
:
if
self
.
verbose
:
print
"
DB: schema version mismatch: expected %d, got %d
"
\
%
(
self
.
schema_version
,
v
)
print
(
"
DB: schema version mismatch: expected %d, got %d
"
%
(
self
.
schema_version
,
v
)
)
raise
SchemaMismatch
(
repr
(
v
))
self
.
_initViews
(
c
)
return
...
...
@@ -633,7 +634,7 @@ class DB:
def
do_parse
(
packages
):
if
self
.
verbose
:
print
"
reading
"
+
`
filename
`
print
(
"
reading
"
+
repr
(
filename
))
re_source
=
re
.
compile
\
(
r
'
^([a-zA-Z0-9.+-]+)(?:\s+\(([a-zA-Z0-9.+:~-]+)\))?$
'
)
...
...
@@ -713,13 +714,13 @@ class DB:
"""
Reads a directory of package files.
"""
if
self
.
verbose
:
print
"
readPackages:
"
print
(
"
readPackages:
"
)
self
.
_readSourcePackages
(
cursor
,
directory
)
self
.
_readBinaryPackages
(
cursor
,
directory
)
if
self
.
verbose
:
print
"
finished
"
print
(
"
finished
"
)
def
_readSourcePackages
(
self
,
cursor
,
directory
):
"""
Reads from directory with source package files.
"""
...
...
@@ -727,7 +728,7 @@ class DB:
re_sources
=
re
.
compile
(
r
'
.*/([a-z-]+)_([a-z-]*)_([a-z-]+)_Sources$
'
)
if
self
.
verbose
:
print
"
reading source packages
"
print
(
"
reading source packages
"
)
for
filename
in
glob
.
glob
(
directory
+
'
/*_Sources
'
):
match
=
re_sources
.
match
(
filename
)
...
...
@@ -768,7 +769,7 @@ class DB:
r
'
.*/([a-z-]+)_([a-z-]*)_([a-z-]+)_([a-z0-9-]+)_Packages$
'
)
if
self
.
verbose
:
print
"
reading binary packages
"
print
(
"
reading binary packages
"
)
# First check for any changes.
...
...
@@ -786,7 +787,7 @@ class DB:
break
if
not
changed
:
if
self
.
verbose
:
print
"
finished (no changes)
"
print
(
"
finished (no changes)
"
)
return
# Real import. We have to re-read all Packages files even if
...
...
@@ -825,11 +826,11 @@ class DB:
if
unchanged
:
if
self
.
verbose
:
print
"
finished (no changes)
"
print
(
"
finished (no changes)
"
)
return
if
self
.
verbose
:
print
"
deleting old data
"
print
(
"
deleting old data
"
)
cursor
.
execute
(
"
DELETE FROM binary_packages
"
)
self
.
_clearVersions
(
cursor
)
...
...
@@ -847,7 +848,7 @@ class DB:
yield
key
+
(
archs
,)
if
self
.
verbose
:
print
"
storing binary package data
"
print
(
"
storing binary package data
"
)
cursor
.
executemany
(
"""
INSERT INTO binary_packages
...
...
@@ -880,7 +881,7 @@ class DB:
def
readBugs
(
self
,
cursor
,
path
):
if
self
.
verbose
:
print
"
readBugs:
"
print
(
"
readBugs:
"
)
def
clear_db
(
cleared
=
[
False
]):
# Avoid clearing the database multiple times.
...
...
@@ -908,7 +909,7 @@ class DB:
clear_db
()
if
self
.
verbose
:
print
"
reading
"
+
`
source.name
`
print
(
"
reading
"
+
repr
(
source
.
name
))
for
bug
in
source
:
try
:
...
...
@@ -945,7 +946,7 @@ class DB:
break
if
unchanged
:
if
self
.
verbose
:
print
"
finished (no changes)
"
print
(
"
finished (no changes)
"
)
return
clear_db
()
...
...
@@ -966,13 +967,13 @@ class DB:
read_one
(
cls
(
path
+
srcpath
))
if
self
.
verbose
:
print
"
update removed packages
"
print
(
"
update removed packages
"
)
self
.
readRemovedPackages
(
cursor
,
path
+
source_removed_packages
)
errors
=
[]
if
self
.
verbose
:
print
"
check cross-references
"
print
(
"
check cross-references
"
)
for
(
bug
,)
in
cursor
.
execute
(
"""
SELECT DISTINCT target FROM bugs_xref
...
...
@@ -982,7 +983,7 @@ class DB:
errors
.
append
(
"
reference to unknown bug
"
+
bug
)
if
self
.
verbose
:
print
"
copy notes
"
print
(
"
copy notes
"
)
# Copy notes from DSA/DTSA/DLA to CVE.
...
...
@@ -1037,7 +1038,7 @@ class DB:
raise
InsertError
(
errors
)
if
self
.
verbose
:
print
"
finished
"
print
(
"
finished
"
)
def
availableReleases
(
self
,
cursor
=
None
):
"""
Returns a list of tuples (RELEASE, ARCHIVE,
...
...
@@ -1088,15 +1089,15 @@ class DB:
"""
Updates the linear version table.
"""
if
self
.
verbose
:
print
"
updateVersions:
"
print
(
"
updateVersions:
"
)
for
x
in
cursor
.
execute
(
"
SELECT * FROM version_linear_order LIMIT 1
"
):
if
self
.
verbose
:
print
"
finished (no changes)
"
print
(
"
finished (no changes)
"
)
return
if
self
.
verbose
:
print
"
reading
"
print
(
"
reading
"
)
versions
=
[]
for
(
v
,)
in
cursor
.
execute
(
...
...
@@ -1107,18 +1108,18 @@ class DB:
versions
.
append
(
debian_support
.
Version
(
v
))
if
self
.
verbose
:
print
"
calculating linear order
"
print
(
"
calculating linear order
"
)
versions
.
sort
()
if
self
.
verbose
:
print
"
storing linear order
"
print
(
"
storing linear order
"
)
for
v
in
versions
:
cursor
.
execute
(
"
INSERT INTO version_linear_order (version) VALUES (?)
"
,
(
str
(
v
),))
if
self
.
verbose
:
print
"
updating package notes
"
print
(
"
updating package notes
"
)
cursor
.
execute
(
"""
UPDATE package_notes
SET fixed_version_id = (SELECT id FROM version_linear_order
...
...
@@ -1126,14 +1127,14 @@ class DB:
WHERE fixed_version IS NOT NULL
"""
)
if
self
.
verbose
:
print
"
updating source packages
"
print
(
"
updating source packages
"
)
cursor
.
execute
(
"""
UPDATE source_packages
SET version_id = (SELECT id FROM version_linear_order
WHERE version = source_packages.version)
"""
)
if
self
.
verbose
:
print
"
finished
"
print
(
"
finished
"
)
def
calculateVulnerabilities
(
self
,
cursor
):
"""
Calculate vulnerable packages.
...
...
@@ -1149,8 +1150,8 @@ class DB:
self
.
_updateVersions
(
cursor
)
if
self
.
verbose
:
print
"
calculateVulnerabilities:
"
print
"
checking version consistency in package notes
"
print
(
"
calculateVulnerabilities:
"
)
print
(
"
checking version consistency in package notes
"
)
# The following does not work because stable->security ->
# testing -> unstable propagation is no longer available.
...
...
@@ -1175,7 +1176,7 @@ class DB:
%
(
b
.
source_file
,
b
.
source_line
,
`rel`
,
rel_ver
))
if
self
.
verbose
:
print
"
checking source packages
"
print
(
"
checking source packages
"
)
cursor
.
execute
(
"""
UPDATE package_notes SET package_kind =
'
unknown
'
WHERE package_kind IN (
'
source
'
,
'
binary
'
)
"""
)
...
...
@@ -1206,13 +1207,13 @@ class DB:
return
result
if
self
.
verbose
:
print
"
remove old status
"
print
(
"
remove old status
"
)
cursor
.
execute
(
"
DELETE FROM source_package_status
"
)
cursor
.
execute
(
"
DELETE FROM bug_status
"
)
if
self
.
verbose
:
print
"
calculate package status
"
print
"
source packages (unqualified)
"
print
(
"
calculate package status
"
)
print
(
"
source packages (unqualified)
"
)
cursor
.
execute
(
"""
INSERT INTO source_package_status
...
...
@@ -1229,7 +1230,7 @@ class DB:
# therefore we use INSERT OR REPLACE.
if
self
.
verbose
:
print
"
source packages (qualified)
"
print
(
"
source packages (qualified)
"
)
cursor
.
execute
(
"""
INSERT OR REPLACE INTO source_package_status
SELECT n.bug_name, p.rowid,
...
...
@@ -1244,7 +1245,7 @@ class DB:
# assign nvd urgencies to those that have not yet been assigned
if
self
.
verbose
:
print
"
insert nvd urgencies
"
print
(
"
insert nvd urgencies
"
)
cursor
.
execute
(
"""
REPLACE INTO source_package_status
SELECT s.bug_name, s.package, s.vulnerable,
...
...
@@ -1271,7 +1272,7 @@ class DB:
# Calculate the release-specific bug status.
if
self
.
verbose
:
print
"
calculate release status
"
print
(
"
calculate release status
"
)
c
=
self
.
cursor
()
...
...
@@ -2095,13 +2096,13 @@ class DB:
AND sp.release = binary_packages.release
AND sp.archive = binary_packages.archive)
"""
):
print
"
error: binary package without source package
"
print
"
binary package:
"
,
package
print
"
release:
"
,
release
print
(
"
error: binary package without source package
"
)
print
(
"
binary package:
"
,
package
)
print
(
"
release:
"
,
release
)
if
archive
:
print
"
archive:
"
,
archive
print
"
architecture:
"
,
architecture
print
"
missing source package:
"
,
source
print
(
"
archive:
"
,
archive
)
print
(
"
architecture:
"
,
architecture
)
print
(
"
missing source package:
"
,
source
)
for
(
package
,
release
,
archive
,
architecture
,
version
,
source
,
source_version
)
\
...
...
@@ -2118,15 +2119,15 @@ class DB:
debian_support
.
Version
(
source_version
))
assert
relation
!=
0
if
relation
<=
0
:
print
"
error: binary package is older than source package
"
print
(
"
error: binary package is older than source package
"
)
else
:
print
"
warning: binary package is newer than source package
"
print
"
binary package: %s (%s)
"
%
(
package
,
version
)
print
"
source package: %s (%s)
"
%
(
source
,
source_version
)
print
"
release:
"
,
release
print
(
"
warning: binary package is newer than source package
"
)
print
(
"
binary package: %s (%s)
"
%
(
package
,
version
)
)
print
(
"
source package: %s (%s)
"
%
(
source
,
source_version
)
)
print
(
"
release:
"
,
release
)
if
archive
:
print
"
archive:
"
,
archive
print
"
architecture:
"
,
architecture
print
(
"
archive:
"
,
archive
)
print
(
"
architecture:
"
,
architecture
)
def
test
():
assert
mergeLists
(
u
''
,
u
''
)
==
[],
mergeLists
(
u
''
,
u
''
)
...
...