コード例 #1
0
def nbelement(collection=None):
    if collection is None or collection == "cve":
        collection = "cves"
    return getSize(collection)
コード例 #2
0
argparser.add_argument(
    "-a", action="store_true", default=False, help="force populating the CVE database"
)
argparser.add_argument(
    "-f", action="store_true", default=False, help="force update of the CVE database"
)
argparser.add_argument("-v", action="store_true", help="verbose output")
args = argparser.parse_args()


if __name__ == "__main__":
    cvd = CVEDownloads()

    cvd.logger.debug("{}".format(" ".join(sys.argv)))

    if args.u:

        last_modified = cvd.update()

    elif args.p:
        c = getSize(cvd.feed_type.lower())
        if args.v:
            cvd.logger.info(str(c))
        if c > 0 and args.a is False:
            cvd.logger.info("database already populated")
        else:
            last_modified = cvd.populate()

    else:
        argparser.print_help()
コード例 #3
0
ファイル: db_mgmt_admin.py プロジェクト: IMULMUL/cve-search
def isLastAdmin(user):
    if dbh.connection.isSingleMaster(user):
        sys.exit(exits["lastMaster"])


# script run
try:
    if args.a:
        username = args.a
        if username.strip() == "_dummy_":
            sys.exit(exits["dummy"])
        if dbh.connection.userExists(username):
            sys.exit(exits["userInDb"])
        # set master if db is empty
        if getSize(col) > 0:
            masterLogin()
            password = promptNewPass()
            dbh.connection.addUser(username, password, localOnly=args.l)
        else:
            password = promptNewPass()
            dbh.connection.addUser(username,
                                   password,
                                   admin=True,
                                   localOnly=args.l)
        sys.exit("User added")
    elif args.c:
        username = args.c
        verifyPass(getpass.getpass("Old password:"), username)
        password = promptNewPass()
        dbh.connection.changePassword(username, password)