mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-31 21:01:07 +00:00
suspicious-source: Replace with total rewrite in Python using python-magic.
This commit is contained in:
parent
633d60d71d
commit
c1bdfe3f6d
3
debian/changelog
vendored
3
debian/changelog
vendored
@ -20,6 +20,7 @@ ubuntu-dev-tools (0.101) UNRELEASED; urgency=low
|
|||||||
- Output every executed command in verbose mode
|
- Output every executed command in verbose mode
|
||||||
- Print proper error message if the dsc file is malformed.
|
- Print proper error message if the dsc file is malformed.
|
||||||
* update-maintainer: Add a --quiet option.
|
* update-maintainer: Add a --quiet option.
|
||||||
|
* suspicious-source: Replace with total rewrite in Python using python-magic.
|
||||||
|
|
||||||
[ Michael Bienia ]
|
[ Michael Bienia ]
|
||||||
* ubuntutools/lpapi/lpapicache.py: Use the new LP API method
|
* ubuntutools/lpapi/lpapicache.py: Use the new LP API method
|
||||||
@ -29,7 +30,7 @@ ubuntu-dev-tools (0.101) UNRELEASED; urgency=low
|
|||||||
* requestsync: Fix bug where the variable 'hasLP' is not always set
|
* requestsync: Fix bug where the variable 'hasLP' is not always set
|
||||||
(lp: #607874).
|
(lp: #607874).
|
||||||
|
|
||||||
-- Benjamin Drung <bdrung@ubuntu.com> Mon, 02 Aug 2010 15:35:49 +0200
|
-- Benjamin Drung <bdrung@ubuntu.com> Mon, 02 Aug 2010 20:26:17 +0200
|
||||||
|
|
||||||
ubuntu-dev-tools (0.100) maverick; urgency=low
|
ubuntu-dev-tools (0.100) maverick; urgency=low
|
||||||
|
|
||||||
|
1
debian/control
vendored
1
debian/control
vendored
@ -35,6 +35,7 @@ Recommends: bzr,
|
|||||||
libwww-perl,
|
libwww-perl,
|
||||||
pbuilder | cowdancer | sbuild,
|
pbuilder | cowdancer | sbuild,
|
||||||
perl-modules,
|
perl-modules,
|
||||||
|
python-magic,
|
||||||
python-soappy,
|
python-soappy,
|
||||||
reportbug (>= 3.39ubuntu1)
|
reportbug (>= 3.39ubuntu1)
|
||||||
Suggests: qemu-kvm-extras-static
|
Suggests: qemu-kvm-extras-static
|
||||||
|
@ -1,61 +1,110 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# Copyright (c) 2010, Benjamin Drung <bdrung@ubuntu.com>
|
||||||
#
|
#
|
||||||
# Copyright 2007 (C) Siegfried-A. Gevatter <rainct@ubuntu.com>
|
# Permission to use, copy, modify, and/or distribute this software for any
|
||||||
# Based upon a script by Martin Pitt <martin.pitt@ubuntu.com>
|
# purpose with or without fee is hereby granted, provided that the above
|
||||||
|
# copyright notice and this permission notice appear in all copies.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
# modify it under the terms of the GNU General Public License
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
# as published by the Free Software Foundation; either version 3
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
# of the License, or (at your option) any later version.
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
#
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
# This program is distributed in the hope that it will be useful,
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# See file /usr/share/common-licenses/GPL for more details.
|
|
||||||
#
|
|
||||||
# This script outputs a list of files which are not common source files. This
|
|
||||||
# should be run in the root of a source tree to find files which might not be
|
|
||||||
# the "preferred form of modification" that the GPL and other licenses require.
|
|
||||||
|
|
||||||
FILES="*.h *.c *.cc *.cpp *.py *.sh *.txt *.text *.3 *.m4 *.xml *.html *.php \
|
import magic
|
||||||
*.php3 *.php4 *.class *.form *.module *.cfg *.conf *.config *.odt \
|
import optparse
|
||||||
*.odp *.tex *.sla *.scd Makefile Makefile.am Makefile.in configure \
|
import os
|
||||||
configure.ac *.diff *.debdiff *.patch *.dpatch config.sub config.guess \
|
import sys
|
||||||
depcomp *.docbook *.desktop *.menu AUTHORS INSTALL NEWS README TODO \
|
|
||||||
COPYING LICENSE ChangeLog *.ui *.glade *.gladep *.po *.pot *.ts *.pro \
|
|
||||||
*.svg *.png *.bmp *.gif *.xpm *.hh *.in *.cs *.1 *.2 *.3 *.4 *.5 *.6 \
|
|
||||||
*.7 *.8 *.9 *.hs *.el *.css"
|
|
||||||
|
|
||||||
IGNORE=".bzr CVS .svn debian .git"
|
default_whitelisted_mimetypes = [
|
||||||
|
"application/xml",
|
||||||
|
"application/x-elc",
|
||||||
|
"application/x-empty",
|
||||||
|
"application/x-symlink",
|
||||||
|
"audio/x-wav",
|
||||||
|
"image/gif",
|
||||||
|
"image/jpeg",
|
||||||
|
"image/png",
|
||||||
|
"image/svg+xml",
|
||||||
|
"image/x-icns",
|
||||||
|
"image/x-ico",
|
||||||
|
"image/x-ms-bmp",
|
||||||
|
"image/x-portable-pixmap",
|
||||||
|
"message/rfc822",
|
||||||
|
"text/html",
|
||||||
|
"text/plain",
|
||||||
|
"text/rtf",
|
||||||
|
"text/troff",
|
||||||
|
"text/x-asm",
|
||||||
|
"text/x-c",
|
||||||
|
"text/x-c++",
|
||||||
|
"text/x-diff",
|
||||||
|
"text/x-fortran",
|
||||||
|
"text/x-java",
|
||||||
|
"text/x-lisp",
|
||||||
|
"text/x-m4",
|
||||||
|
"text/x-makefile",
|
||||||
|
"text/x-msdos-batch",
|
||||||
|
"text/x-pascal",
|
||||||
|
"text/x-perl",
|
||||||
|
"text/x-php",
|
||||||
|
"text/x-po",
|
||||||
|
"text/x-shellscript",
|
||||||
|
"text/x-tex",
|
||||||
|
"text/x-texinfo",
|
||||||
|
]
|
||||||
|
|
||||||
|
default_whitelisted_extensions = [
|
||||||
|
".rsa"
|
||||||
|
]
|
||||||
|
|
||||||
COMMAND=(find ! \( )
|
def main(whitelisted_mimetypes, whitelisted_extensions, directory, verbose=False):
|
||||||
|
ms = magic.open(magic.MAGIC_MIME_TYPE)
|
||||||
|
ms.load()
|
||||||
|
|
||||||
firstDone=False
|
for root, dirs, files in os.walk(directory):
|
||||||
for pattern in $FILES
|
for f in files:
|
||||||
do
|
mimetype = ms.file(os.path.join(root, f))
|
||||||
if [[ $firstDone != True ]]; then
|
if mimetype not in whitelisted_mimetypes:
|
||||||
COMMAND+=( -name $pattern); firstDone=True
|
if not filter(lambda x: f.lower().endswith(x), whitelisted_extensions):
|
||||||
else
|
if verbose:
|
||||||
COMMAND+=( -o -name $pattern)
|
print "%s (%s)" % (os.path.join(root, f), mimetype)
|
||||||
fi
|
else:
|
||||||
done
|
print os.path.join(root, f)
|
||||||
|
for d in (".bzr", "CVS", ".git", ".svn"):
|
||||||
|
if d in dirs:
|
||||||
|
dirs.remove(d)
|
||||||
|
|
||||||
COMMAND+=( \) \( )
|
if __name__ == "__main__":
|
||||||
|
script_name = os.path.basename(sys.argv[0])
|
||||||
|
usage = "%s [options]" % (script_name)
|
||||||
|
epilog = "See %s(1) for more info." % (script_name)
|
||||||
|
parser = optparse.OptionParser(usage=usage, epilog=epilog)
|
||||||
|
|
||||||
firstDone=False
|
parser.add_option("-v", "--verbose", help="print more information",
|
||||||
for pattern in $IGNORE
|
dest="verbose", action="store_true", default=False)
|
||||||
do
|
parser.add_option("-d", "--directory",
|
||||||
if [[ $firstDone != True ]]; then
|
help="check the files in the specified directory",
|
||||||
COMMAND+=( -name $pattern -prune); firstDone=True
|
dest="directory", default=".")
|
||||||
else
|
parser.add_option("-m", "--mimetype", metavar="MIMETYPE",
|
||||||
COMMAND+=( -o -name $pattern -prune)
|
help="Add MIMETYPE to list of whitelisted mimetypes.",
|
||||||
fi
|
dest="whitelisted_mimetypes", action="append",
|
||||||
done
|
default=default_whitelisted_mimetypes)
|
||||||
|
parser.add_option("-e", "--extension", metavar="EXTENSION",
|
||||||
|
help="Add EXTENSION to list of whitelisted extensions.",
|
||||||
|
dest="whitelisted_extensions", action="append",
|
||||||
|
default=default_whitelisted_extensions)
|
||||||
|
|
||||||
COMMAND+=( -o -type f -print \))
|
(options, args) = parser.parse_args()
|
||||||
COMMAND="${COMMAND[@]}"
|
|
||||||
|
|
||||||
$COMMAND # Execute the command
|
if len(args) != 0:
|
||||||
|
print >> sys.stderr, "%s: This script does not take any additional parameters." % \
|
||||||
|
(script_name)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
whitelisted_extensions = map(lambda x: x.lower(), options.whitelisted_extensions)
|
||||||
|
main(options.whitelisted_mimetypes, whitelisted_extensions,
|
||||||
|
options.directory, options.verbose)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user