Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA: Fix black & flake8 issues and add clang-format stage #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: lint

on:
pull_request:
branches: [ master ]
branches: [ "**" ]
push:
branches: [ master ]

Expand Down Expand Up @@ -30,3 +30,11 @@ jobs:
- run: |
black --version
black --check --diff .
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: sudo apt-get install clang-format
- run: |
clang-format -style="{IndentWidth: 4}" --dry-run --Werror -i *.cpp *.H
working-directory: pintool
6 changes: 3 additions & 3 deletions analysis/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def read_and_advance(chunk, idx, format_type, length):
# This parsing requires a naming scheme like: `key1.key`
key_index = int(set(keys).pop().replace("key", "").replace(".", ""))

for (trace_file, key_file) in zip(files, keys):
for trace_file, key_file in zip(files, keys):
with open(trace_file, "rb") as tf, open(key_file, "rb") as kf:
trace = tf.read()
key = kf.read()
Expand Down Expand Up @@ -508,7 +508,7 @@ def _glt_sort_and_map(mapping_table, data):
# Sort data from big to little wrt to the counts
data = sorted(data.items(), key=lambda kv: kv[1], reverse=True)
# Map addr to new value
for (address, count) in data:
for address, count in data:
if address not in mapping_table:
mapping_table[address] = len(mapping_table.keys())
tmp_data[mapping_table[address]] = count
Expand Down Expand Up @@ -612,7 +612,7 @@ def generic_leakage_test(fixed, random):
# iterate over leaks
debug(0, "Got %d trace differences.", (len(fixedleaks)))
sys.stdout.flush()
for (idx, (fl, rl)) in enumerate(zip(fixedleaks, randomleaks)):
for idx, (fl, rl) in enumerate(zip(fixedleaks, randomleaks)):
msg = {"warning": "", "leak": ""}
assert fl.ip == rl.ip

Expand Down
4 changes: 2 additions & 2 deletions analysis/datastub/leaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,12 +492,12 @@ def is_specific_leak(self):
def max_leak(self):
max_leak = None
if self.is_generic_leak():
max_leak_ns = max(self.nsleak, key=lambda l: l.normalized())
max_leak_ns = max(self.nsleak, key=lambda leak: leak.normalized())
# Remove M_pos, as it does not work properly
# normalized = max(normalized, max(self.nsleak, key=lambda l: 0 if l.nstype == NSPType.Type3 else l.normalized()).normalized())
max_leak = max_leak_ns
if self.is_specific_leak():
max_leak_sp = max(self.spleak, key=lambda l: l.normalized())
max_leak_sp = max(self.spleak, key=lambda leak: leak.normalized())
# Remove M_pos, as it does not work properly
# normalized = max(normalized, max(self.spleak, key=lambda l: 0 if l.sptype == NSPType.Type3 else l.normalized()).normalized())
max_leak = max_leak_sp if max_leak_sp.normalized() > max_leak.normalized() else max_leak
Expand Down
6 changes: 3 additions & 3 deletions analysis/datastub/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ def doprint_generic(self, obj, param1=False):

key_indxs = [e.key.index for e in obj.evidence]
evidences = [[] for _ in range(max(key_indxs) + 1)]
for (idx, key_indx) in enumerate(key_indxs):
for idx, key_indx in enumerate(key_indxs):
evidences[key_indx].append(obj.evidence[idx])

for (idx, evidence) in enumerate(evidences):
for idx, evidence in enumerate(evidences):
entries = Counter(
[entry for ee in evidence for entry in ee.entries]
)
Expand All @@ -209,7 +209,7 @@ def doprint_generic(self, obj, param1=False):
else:
node = f"{node_plain} origin='fixed' {str(evidence[0].key)}"
self.startNode(node)
for (key, value) in entries.items():
for key, value in entries.items():
self.doprint_line(f"{format(key, 'x')}: {value}")
self.endNode(node_plain)

Expand Down
2 changes: 1 addition & 1 deletion analysis/leakage_models/dsa_nonce.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def input_to_lines(input):
num_lines_per_input = len(input_to_lines(inputs[0]))
result = numpy.ndarray((len(inputs), num_lines_per_input), dtype=numpy.int)

for (i, input) in enumerate(inputs):
for i, input in enumerate(inputs):
result[i][:] = [v for k, v in input_to_lines(input)]

return (result, labels)
Loading