Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
demonduck committed Sep 13, 2017
1 parent 70cdd9e commit b86049a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
# Autodoc settings
autoclass_content = 'class'
autodoc_mock_imports = ['httplib2', 'oauth2client', 'apiclient', 'mongoengine',
'django', 'bson', 'distorm3', 'mongoengine.queryset',
'bson.objectid']
'django', 'capstone', 'mongoengine.queryset']

class _MyMockModule(sphinx.ext.autodoc._MockModule):
'''Class created to get around autodoc issues with server's dependencies.'''
Expand Down
13 changes: 7 additions & 6 deletions server/first_core/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@
from functools import wraps

# Django Modules
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponse, HttpRequest
from django.shortcuts import render, redirect
from django.urls import reverse

# FIRST Modules
# TODO: Use DBManager to get user objects and do User operations
from first.settings import CONFIG
from first_core.models import User
from first_core.error import FIRSTError

# Thirdy Party
import httplib2
from oauth2client import client
from apiclient import discovery
from mongoengine.queryset import DoesNotExist



Expand Down Expand Up @@ -118,7 +119,7 @@ class Authentication():
def __init__(self, request):
self.request = request
redirect_uri = request.build_absolute_uri(reverse('www:oauth', kwargs={'service' : 'google'}))
secret = os.environ.get('GOOGLE_SECRET', '/usr/local/etc/google_secret.json')
secret = CONFIG.get('oauth_path', '/usr/local/etc/google_secret.json')
try:
self.flow = {'google' : client.flow_from_clientsecrets(secret,
scope=['https://www.googleapis.com/auth/userinfo.profile',
Expand Down Expand Up @@ -200,7 +201,7 @@ def login_step_2(self, auth_code, url, login=True):

return redirect(url)

except DoesNotExist:
except ObjectDoesNotExist:
self.request.session.flush()
raise FIRSTAuthError('User is not registered.')

Expand Down Expand Up @@ -236,7 +237,7 @@ def register_user(self):
user = None
continue

except DoesNotExist:
except ObjectDoesNotExist:
pass

# Create random 4 digit value for the handle
Expand All @@ -248,7 +249,7 @@ def register_user(self):
user = User.objects.get(handle=handle, number=num)
user = None

except DoesNotExist:
except ObjectDoesNotExist:
user = User(name=name,
email=email,
api_key=api_key,
Expand All @@ -269,5 +270,5 @@ def get_user_data(email):
user = User.objects.get(email=email)
return user

except DoesNotExist:
except ObjectDoesNotExist:
return None
6 changes: 2 additions & 4 deletions server/first_core/dbs/builtin_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
from hashlib import md5

# Third Party Modules
import bson

from django.utils import timezone
from django.core.paginator import Paginator
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
Expand Down Expand Up @@ -161,14 +159,14 @@ def get_function(self, opcodes, architecture, apis, create=False, **kwargs):

try:
function = Function.objects.get(sha256=sha256_hash,
opcodes=bson.Binary(opcodes),
opcodes=opcodes,
architecture=architecture) #,
#apis__api=apis)
except ObjectDoesNotExist:
if create:
# Create function and add it to sample
function = Function.objects.create( sha256=sha256_hash,
opcodes=bson.Binary(opcodes),
opcodes=opcodes,
architecture=architecture)

apis_ = [FunctionApis.objects.get_or_create(x)[0] for x in apis]
Expand Down
2 changes: 1 addition & 1 deletion server/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def profile(request):
if not user:
return redirect(reverse('www:index'))

count = Function.objects(metadata__user=user).count()
count = Function.objects.filter(metadata__user=user).count()
data = {'title' : 'Profile',
'user' : user.dump(True),
'metadata_count' : count}
Expand Down

0 comments on commit b86049a

Please sign in to comment.