summaryrefslogtreecommitdiff
path: root/monitor/josef_experimental.py
diff options
context:
space:
mode:
Diffstat (limited to 'monitor/josef_experimental.py')
-rwxr-xr-xmonitor/josef_experimental.py130
1 files changed, 71 insertions, 59 deletions
diff --git a/monitor/josef_experimental.py b/monitor/josef_experimental.py
index 14b8e99..7f1f7d6 100755
--- a/monitor/josef_experimental.py
+++ b/monitor/josef_experimental.py
@@ -11,12 +11,12 @@ from datetime import datetime as dt
-parser = argparse.ArgumentParser(description="")
-parser.add_argument('--domain', default=None, help="RTFM")
-parser.add_argument('--log', default=None, help="RTFM")
-parser.add_argument('--exclude-expired', action='store_true', help="RTFM")
+# parser = argparse.ArgumentParser(description="")
+# parser.add_argument('--domain', default=None, help="RTFM")
+# parser.add_argument('--log', default=None, help="RTFM")
+# parser.add_argument('--exclude-expired', action='store_true', help="RTFM")
-args = parser.parse_args()
+# args = parser.parse_args()
monitored_domains = [
"google.com",
@@ -27,62 +27,74 @@ monitored_domains = [
]
-
-if args.domain:
- db = db_open()
- raw = db_lookup_domain(db, args.domain)
-else:
- print "No domain selected!"
- sys.exit()
-
-cur_time = dt.now()
-count_valid = 0
-count_all = 0
-for item in raw:
- # print item + '}', type(item)
- entry = json.loads((item + '}').replace("'", '"'))
- # print entry, type(entry)
- success = True
- not_after_time = dt.strptime(entry["not_after"], "%b %d %H:%M:%S %Y GMT")
- not_before_time = dt.strptime(entry["not_before"], "%b %d %H:%M:%S %Y GMT")
-
-
- if args.log:
- if args.log in entry["log"]:
- pass
- else:
- success = False
-
- if cur_time > not_after_time:
- expired = True
- elif cur_time < not_before_time:
- expired = True
- else:
- expired = False
-
- # Exclude expired
- if args.exclude_expired and expired:
- success = False
+db = db_open("./tmpdatabase")
+
+db_add_domain(db, "www.cox.a.com", "{dummydata}")
+# print db.Get("com")
+# print db.Get("a.com")
+# print db.Get("cox.a.com")
+# print db.Get("www.cox.a.com")
+print db_lookup_domain(db, "www.cox.a.com")
+
+
+# if args.domain:
+# db = db_open()
+# raw = db_lookup_domain(db, args.domain)
+# else:
+# print "No domain selected!"
+# sys.exit()
+
+# cur_time = dt.now()
+# count_valid = 0
+# count_all = 0
+# for item in raw:
+# # print item + '}', type(item)
+# try:
+# entry = json.loads((item + '}').replace("'", '"'))
+# except:
+# print (item + '}').replace("'", '"')
+# # print entry, type(entry)
+# success = True
+# not_after_time = dt.strptime(entry["not_after"], "%b %d %H:%M:%S %Y GMT")
+# not_before_time = dt.strptime(entry["not_before"], "%b %d %H:%M:%S %Y GMT")
+
+
+# if args.log:
+# if args.log in entry["log"]:
+# pass
+# else:
+# success = False
+
+# if cur_time > not_after_time:
+# expired = True
+# elif cur_time < not_before_time:
+# expired = True
+# else:
+# expired = False
+
+# # Exclude expired
+# if args.exclude_expired and expired:
+# success = False
- # Set count matches
- if success:
- count_all += 1
- if not expired:
- count_valid += 1
-
- # Print matching
- if success:
- s = entry["subject"].split("CN=")[1] + \
- " certified by " + entry["issuer"].split("CN=")[1] + \
- " (" + entry["log"] + ") "
- if expired:
- print "(NOT VALID) " + s
- else:
- print "(VALID) " + s
-
-
-print str(count_all) + " matches found."
+# # Set count matches
+# if success:
+# count_all += 1
+# if not expired:
+# count_valid += 1
+
+# # Print matching
+# if success:
+# s = entry["subject"].split("CN=")[1] + \
+# " certified by " + entry["issuer"].split("CN=")[1] + \
+# " (" + entry["log"] + ") "
+# if expired:
+# print "(NOT VALID) " + s
+# else:
+# print "(VALID) " + s
+
+
+# print str(count_all) + " matches found."
# print res