Skip to content

Commit cea0681

Browse files
authored
Merge branch 'master' into nirizr/basicblocks
2 parents ad843ee + d304970 commit cea0681

File tree

16 files changed

+131
-130
lines changed

16 files changed

+131
-130
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ server/db.sqlite3
9696
Thumbs.db
9797
*.un~
9898
*.swp
99+
100+
# server private key file
101+
server/rematch/.rematch_secret.key

.travis.yml

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ language: python
33
matrix:
44
include:
55
- python: "2.7"
6-
env: PROJECT=idaplugin ENV=conda
6+
env: PROJECT=idaplugin
77
- python: "2.7"
8-
env: PROJECT=server DJANGO_SETTINGS_MODULE='rematch.settings.debug' ENV=conda
8+
env: PROJECT=server DJANGO_SETTINGS_MODULE='rematch.settings.debug'
99
services:
1010
- mysql
1111
- rabbitmq
1212
- python: "3.5"
13-
env: PROJECT=server DJANGO_SETTINGS_MODULE='rematch.settings.production' ENV=conda
13+
env: PROJECT=server DJANGO_SETTINGS_MODULE='rematch.settings.production'
1414
services:
1515
- mysql
1616
- rabbitmq
@@ -19,6 +19,8 @@ matrix:
1919
services: docker
2020
- python: "2.7"
2121
env: PROJECT=setup.py
22+
- python: "3.6"
23+
env: PROJECT=setup.py
2224

2325
branches:
2426
only:
@@ -34,47 +36,46 @@ before_install:
3436

3537
install:
3638
- set +vx;
37-
- if [ ${ENV} = "conda" ]; then
38-
if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
39-
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
40-
else
41-
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
42-
fi;
43-
bash ./miniconda.sh -b -p ${HOME}/miniconda;
44-
export PATH=${HOME}/miniconda/bin:$PATH;
45-
conda info -a;
46-
47-
if [ ${PROJECT} = "server" ]; then
48-
conda install --yes python=${TRAVIS_PYTHON_VERSION} atlas numpy scipy scikit-learn;
49-
fi;
50-
if [ ${PROJECT} = "idaplugin" ]; then
51-
conda install --yes python=${TRAVIS_PYTHON_VERSION} pyqt;
52-
fi;
53-
if [ -f tests/${PROJECT}/requirements.txt ]; then
54-
pip install -r tests/${PROJECT}/requirements.txt ;
55-
fi;
56-
if [ -f ${PROJECT}/requirements.txt ]; then pip install -r ${PROJECT}/requirements.txt ; fi ;
57-
fi;
39+
- pip install --upgrade pip setuptools wheel
5840
- if [ ${ENV} = "docker" ]; then
5941
service docker start ;
6042
docker-compose -f ./${PROJECT}/docker-compose.yml build ;
6143
docker-compose -f ./${PROJECT}/docker-compose.yml up -d ;
6244
if [ -f ./tests/${PROJECT}/requirements.txt ]; then
6345
docker-compose -f ./${PROJECT}/docker-compose.yml exec web pip install -r ./tests/requirements.txt ;
6446
fi ;
65-
fi;
66-
- pip install flake8 coveralls pytest-cov ;
47+
else
48+
if [ ${PROJECT} = "idaplugin" ]; then
49+
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
50+
bash ./miniconda.sh -b -p ${HOME}/miniconda;
51+
export PATH=${HOME}/miniconda/bin:$PATH;
52+
conda info -a;
53+
conda install --yes python=${TRAVIS_PYTHON_VERSION} pyqt;
54+
else
55+
pip install --only-binary=numpy,scipy numpy scipy ;
56+
fi ;
6757

68-
before_script:
69-
- if [ ${PROJECT} = "server" ]; then mysql -e 'SHOW VARIABLES LIKE "%version%";' ; fi ;
58+
if [ -f tests/${PROJECT}/requirements.txt ]; then
59+
pip install -r tests/${PROJECT}/requirements.txt ;
60+
fi ;
61+
if [ -f ${PROJECT}/requirements.txt ]; then
62+
pip install -r ${PROJECT}/requirements.txt ;
63+
fi ;
64+
fi ;
65+
- pip install flake8 coveralls pytest-cov ;
7066

7167
script:
7268
- flake8 ./${PROJECT} --show-source --statistics
7369
- if [ -d ./tests/${PROJECT} ]; then flake8 ./tests/${PROJECT} --show-source ; fi ;
74-
- if [ -d ./tests/${PROJECT} ] && [ ${ENV} = "conda" ]; then PYTHONPATH=. py.test ./${PROJECT} ./tests/${PROJECT} --verbose --cov-report= --cov=$PROJECT ; fi ;
75-
- if [ -d ./tests/${PROJECT} ] && [ ${ENV} = "docker" ]; then docker-compose -f ./${PROJECT}/docker-compose.yml exec web py.test ./ --verbose ; fi ;
70+
- if [ -d ./tests/${PROJECT} ]; then
71+
if [ "${ENV}" = "docker" ]; then
72+
docker-compose -f ./${PROJECT}/docker-compose.yml exec web py.test ./ --verbose ;
73+
else
74+
PYTHONPATH=. py.test ./${PROJECT} ./tests/${PROJECT} --verbose --cov-report= --cov=$PROJECT ;
75+
fi ;
76+
fi ;
77+
- if [ ${PROJECT} = "setup.py" ]; then python ./setup.py server install ; fi ;
78+
- if [ ${PROJECT} = "setup.py" ]; then python ./setup.py idaplugin install ; fi ;
7679

7780
after_script:
78-
- if [ -d ./tests/${PROJECT} ]; then
79-
if [ ${ENV} != "docker" ]; then coveralls ; fi ;
80-
fi;
81+
- if [ -d ./tests/${PROJECT} ] && [ ${ENV} != "docker" ]; then coveralls ; echo "./tests/${PROJECT}" ; fi ;

README.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
|Read The Docs| |Build Status| |Code Health| |Codacy Badge| |idaplugin PyPI| |server PyPI|
1+
|Read The Docs| |Gitter Chat| |Build Status| |Code Health| |Codacy Badge| |idaplugin PyPI| |server PyPI|
22

33
rematch
44
=======
@@ -135,6 +135,9 @@ python scripting! :D).
135135
.. |Read The Docs| image:: https://readthedocs.org/projects/rematch/badge/?version=latest
136136
:alt: Read The Docs
137137
:target: http://rematch.readthedocs.io/en/latest/?badge=latest
138+
.. |Gitter Chat| image:: https://img.shields.io/gitter/room/rematch/rematch.js.svg
139+
:alt: Gitter Chat
140+
:target: https://gitter.im/rematch/rematch
138141
.. |Build Status| image:: https://travis-ci.org/nirizr/rematch.svg?branch=master
139142
:alt: Build Status
140143
:target: https://travis-ci.org/nirizr/rematch

idaplugin/rematch/actions/match.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ def accept_task(self):
224224

225225
def start_results(self):
226226
self.pbar = QtWidgets.QProgressDialog()
227+
self.pbar.setAutoReset(False)
227228
self.pbar.canceled.connect(self.cancel)
228229
self.pbar.rejected.connect(self.cancel)
229230
self.pbar.setLabelText("Receiving match results...")
@@ -290,6 +291,9 @@ def handle_page(self, response):
290291
self.pbar.setMaximum(self.pbar.maximum() + response['count'])
291292

292293
new_value = max(self.pbar.value(), 0) + len(response['results'])
294+
log('match_action').info("result download progress: {} / {} with {}"
295+
"".format(new_value, self.pbar.maximum(),
296+
self.recieved))
293297
if new_value >= self.pbar.maximum() and len(self.recieved) >= 3:
294298
self.pbar.accept()
295299
else:

idaplugin/rematch/dialogs/widgets.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from ..idasix import QtWidgets, QtCore
22

33
import ida_funcs
4+
import ida_kernwin
45
import idc
56

67
from .. import network
@@ -170,8 +171,8 @@ def label_clicked(self, checked):
170171

171172
def btn_clicked(self, checked):
172173
del checked
173-
f = ida_funcs.choose_func("Choose function to match with database",
174-
self.func.startEA if self.func else 0)
174+
f = ida_kernwin.choose_func("Choose function to match with database",
175+
self.func.startEA if self.func else 0)
175176
if f:
176177
self.set_func(f)
177178
self.changed.emit()

idaplugin/rematch/idasix

server/accounts/views.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
from rest_framework.decorators import api_view
22
from rest_framework.response import Response
3+
from django.core.serializers.json import DjangoJSONEncoder
4+
import json
35

46

57
@api_view(['GET'])
68
def profile(request):
79
user = {"id": request.user.id,
8-
"is_authenticated": request.user.is_authenticated(),
10+
"is_authenticated": request.user.is_authenticated,
911
"is_active": request.user.is_active,
1012
"is_staff": request.user.is_staff,
1113
"is_superuser": request.user.is_superuser,
1214
}
13-
if request.user.is_authenticated():
15+
if request.user.is_authenticated:
1416
user.update({"username": request.user.username,
1517
"first_name": request.user.first_name,
1618
"last_name": request.user.last_name,
1719
"email": request.user.email,
1820
})
19-
return Response(user)
21+
response = json.dumps(user, cls=DjangoJSONEncoder)
22+
return Response(response)

server/collab/matchers/dictionary_matcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def match(cls, source, target):
2222
target_data = [json.loads(d) for d in target_data]
2323

2424
dictvect = skl.feature_extraction.DictVectorizer()
25-
source_matrix = dictvect.fit_transform(source_data)
25+
source_matrix = dictvect.fit(source_data + target_data)
26+
source_matrix = dictvect.transform(source_data)
2627
target_matrix = dictvect.transform(target_data)
2728
print("source matrix: {}, target matrix: {}".format(source_matrix.shape,
2829
target_matrix.shape))

server/collab/models.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class Project(models.Model):
99
created = models.DateTimeField(auto_now_add=True)
10-
owner = models.ForeignKey(User, db_index=True)
10+
owner = models.ForeignKey(User, models.CASCADE, db_index=True)
1111
name = models.CharField(max_length=256)
1212
description = models.TextField()
1313
private = models.BooleanField()
@@ -22,8 +22,9 @@ class Meta(object):
2222

2323
class File(models.Model):
2424
created = models.DateTimeField(auto_now_add=True)
25-
owner = models.ForeignKey(User, db_index=True)
26-
project = models.ForeignKey(Project, null=True, related_name='files')
25+
owner = models.ForeignKey(User, models.CASCADE, db_index=True)
26+
project = models.ForeignKey(Project, models.CASCADE, null=True,
27+
related_name='files')
2728
name = models.CharField(max_length=256)
2829
description = models.TextField()
2930
md5hash = models.CharField(max_length=32, db_index=True,
@@ -38,7 +39,7 @@ def __unicode__(self):
3839

3940
class FileVersion(models.Model):
4041
created = models.DateTimeField(auto_now_add=True)
41-
file = models.ForeignKey(File, related_name='versions')
42+
file = models.ForeignKey(File, models.CASCADE, related_name='versions')
4243
md5hash = models.CharField(max_length=32,
4344
validators=[MinLengthValidator(32)])
4445

@@ -60,8 +61,9 @@ class Instance(models.Model):
6061
(TYPE_EMPTY_FUNCTION, "Empty Function"),
6162
(TYPE_FUNCTION, "Function"))
6263

63-
owner = models.ForeignKey(User, db_index=True)
64-
file_version = models.ForeignKey(FileVersion, related_name='instances')
64+
owner = models.ForeignKey(User, models.CASCADE, db_index=True)
65+
file_version = models.ForeignKey(FileVersion, models.CASCADE,
66+
related_name='instances')
6567
type = models.CharField(max_length=64, choices=TYPE_CHOICES)
6668
offset = models.BigIntegerField()
6769
size = models.BigIntegerField()
@@ -89,8 +91,10 @@ class Vector(models.Model):
8991
(TYPE_MNEMONIC_HASH, "Mnemonic Hash"),
9092
(TYPE_MNEMONIC_HIST, "Mnemonic Hist")]
9193

92-
instance = models.ForeignKey(Instance, related_name='vectors')
93-
file_version = models.ForeignKey(FileVersion, related_name='vectors')
94+
instance = models.ForeignKey(Instance, models.CASCADE,
95+
related_name='vectors')
96+
file_version = models.ForeignKey(FileVersion, models.CASCADE,
97+
related_name='vectors')
9498
type = models.CharField(max_length=64, choices=TYPE_CHOICES)
9599
type_version = models.IntegerField()
96100
data = models.TextField()
@@ -119,29 +123,32 @@ class Task(models.Model):
119123
created = models.DateTimeField(auto_now_add=True)
120124
finished = models.DateTimeField(null=True)
121125

122-
owner = models.ForeignKey(User, db_index=True)
126+
owner = models.ForeignKey(User, models.CASCADE, db_index=True)
123127
status = models.CharField(default=STATUS_PENDING, max_length=64,
124128
choices=STATUS_CHOICES)
125129

126-
source_file_version = models.ForeignKey(FileVersion,
130+
source_file_version = models.ForeignKey(FileVersion, models.CASCADE,
127131
related_name='source_tasks')
128132
# TODO: make sure start > end
129-
source_start = models.PositiveIntegerField(null=True)
130-
source_end = models.PositiveIntegerField(null=True)
133+
source_start = models.BigIntegerField(null=True)
134+
source_end = models.BigIntegerField(null=True)
131135
# TODO: make sure only at least one of target_file/target_project is null
132-
target_file = models.ForeignKey(File, null=True)
133-
target_project = models.ForeignKey(Project, null=True)
136+
target_file = models.ForeignKey(File, models.CASCADE, null=True)
137+
target_project = models.ForeignKey(Project, models.CASCADE, null=True)
134138
matchers = models.TextField(default='[]')
135139

136140
progress = models.PositiveSmallIntegerField(default=0)
137141
progress_max = models.PositiveSmallIntegerField(null=True)
138142

139143

140144
class Match(models.Model):
141-
from_instance = models.ForeignKey(Instance, related_name='from_matches')
142-
to_instance = models.ForeignKey(Instance, related_name='to_matches')
145+
from_instance = models.ForeignKey(Instance, models.CASCADE,
146+
related_name='from_matches')
147+
to_instance = models.ForeignKey(Instance, models.CASCADE,
148+
related_name='to_matches')
143149

144-
task = models.ForeignKey(Task, db_index=True, related_name='matches')
150+
task = models.ForeignKey(Task, models.CASCADE, db_index=True,
151+
related_name='matches')
145152

146153
type = models.CharField(max_length=64, choices=Vector.TYPE_CHOICES)
147154
score = models.FloatField()
@@ -155,6 +162,7 @@ class Annotation(models.Model):
155162
(TYPE_ASSEMBLY, "Assembly"),
156163
(TYPE_PROTOTYPE, "Prototype"))
157164

158-
instance = models.ForeignKey(Instance, related_name='annotations')
165+
instance = models.ForeignKey(Instance, models.CASCADE,
166+
related_name='annotations')
159167
type = models.CharField(max_length=64, choices=TYPE_CHOICES)
160168
data = models.TextField()

server/rematch/celery.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
from __future__ import absolute_import
2-
1+
from __future__ import absolute_import, unicode_literals
32
import os
4-
53
from celery import Celery
6-
import django
74

85
# set the default Django settings module for the 'celery' program.
96
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rematch.settings.production')
10-
django.setup()
117

12-
13-
from django.conf import settings # noqa
148
app = Celery('rematch')
159

16-
# Using a string here means the worker will not have to
17-
# pickle the object when using Windows.
10+
# Using a string here means the worker doesn't have to serialize
11+
# the configuration object to child processes.
1812
app.config_from_object('django.conf:settings')
19-
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
13+
14+
# Load task modules from all registered Django app configs.
15+
app.autodiscover_tasks()

0 commit comments

Comments
 (0)