-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8f61036
Showing
1,151 changed files
with
232,196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Disable statistics for generated documentation | ||
docs/html/* linguist-detectable=false | ||
docs/html/search/* linguist-detectable=false | ||
docs/tests/* linguist-detectable=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: corewar | ||
|
||
on: [push, pull_request] | ||
|
||
env: | ||
EXECUTABLE: corewar | ||
|
||
jobs: | ||
check_coding_style: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/epitech/coding-style-checker:latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Launch coding style checker | ||
run: check.sh $(pwd) $(pwd) | ||
- name: Check coding style | ||
run: | ||
cat coding-style-reports.log; | ||
.github/workflows/display_coding_style | ||
|
||
check_program: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: epitechcontent/epitest-docker | ||
needs: check_coding_style | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Launch "make" | ||
run: make | ||
timeout-minutes: 2 | ||
- name: Launch "make clean" | ||
run: make clean | ||
- name: Check program compilation | ||
run: .github/workflows/check_program_compilation ${{ env.EXECUTABLE }} | ||
- name: Check banned functions | ||
run: .github/workflows/check_banned_functions corewar .github/workflows/authorized_functions.txt | ||
- name: Launch "make tests_run" | ||
run: make tests_run | ||
timeout-minutes: 2 | ||
- name: Check repository size | ||
run: | | ||
make fclean | ||
size=$(du -sm --exclude='.git' | cut -f1) | ||
limit=50 | ||
if [ "$size" -gt "$limit" ]; then | ||
echo "::error title=Repository size::Repository size is too big ($size MB > $limit MB)" | ||
exit 1 | ||
else | ||
echo "::notice title=Repository size::Repository size is correct ($size MB <= $limit MB)" | ||
exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
open | ||
fopen | ||
read | ||
fread | ||
write | ||
fwrite | ||
close | ||
fclose | ||
stat | ||
lstat | ||
lseek | ||
fseek | ||
getline | ||
malloc | ||
realloc | ||
free | ||
memset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/python3 | ||
# Created by Dawoox | ||
# Edited by Nicolas TORO | ||
# https://github.com/Dawoox/efc/tree/main | ||
|
||
import shutil | ||
import subprocess | ||
import sys | ||
import re | ||
from typing import List | ||
|
||
TEXT_RED = '\033[31m' | ||
TEXT_GREEN = '\033[32m' | ||
TEXT_CLEAR = '\033[0m' | ||
|
||
|
||
def get_functions(bin_path: str) -> List[str]: | ||
nm_process = subprocess.run(['nm', '-C', bin_path], stdout=subprocess.PIPE) | ||
if nm_process.returncode != 0: | ||
print('ERROR: nm failed') | ||
exit(1) | ||
lines = nm_process.stdout.decode().split('\n') | ||
f_list = [line.split(' ')[-1] for line in lines if ' U ' in line] | ||
f_list = [fx.split(' ')[-1] for fx in f_list if not fx.startswith('__')] | ||
f_list = [fx.split('@')[0] for fx in f_list] | ||
return f_list | ||
|
||
|
||
def parse_file(file_path: str) -> List[str]: | ||
try: | ||
with open(file_path, 'r') as file: | ||
lines = [line.strip() for line in file.readlines()] | ||
return lines | ||
except FileNotFoundError as e: | ||
print(f"ERROR: Did not found {file_path}") | ||
sys.exit(1) | ||
|
||
|
||
def find_authorized_functions(functions_list: List[str], a_filepath: str) -> List[str]: | ||
af_list = parse_file(a_filepath) | ||
return [func for func in functions_list if not any(re.search(af, func) for af in af_list)] | ||
|
||
|
||
def is_tool_present(tool_name: str) -> bool: | ||
return shutil.which(tool_name) is not None | ||
|
||
|
||
def print_usage() -> None: | ||
print(""" | ||
Usage: python3 main.py /path/to/your/binary [/path/to/authorized_functions.txt] | ||
If you don't specify a path to authorized_functions.txt, the program will | ||
use the default one (./bonus/authorized_functions.txt) | ||
""") | ||
|
||
|
||
def run_analysis(bin_path: str, bf_path: str) -> None: | ||
print(f'Analyzing {bin_path}...') | ||
f_list = get_functions(bin_path) | ||
print(f'Found {len(f_list)} functions') | ||
print('Checking for banned functions...') | ||
a_list = find_authorized_functions(f_list, bf_path) | ||
if len(a_list) == 0: | ||
print(f'{TEXT_GREEN}No banned functions found{TEXT_CLEAR}') | ||
print("::notice title=Banned function:: No banned functions found") | ||
exit(0) | ||
else: | ||
print(f'{TEXT_RED}Found {len(a_list)} banned functions !{TEXT_CLEAR}') | ||
print(f'{TEXT_RED}Banned functions:{TEXT_CLEAR}') | ||
for bf_found in a_list: | ||
print("-" + TEXT_RED + bf_found + TEXT_CLEAR) | ||
print("::error title=Banned function found::" + bf_found) | ||
exit(1) | ||
|
||
|
||
def main(): | ||
if len(sys.argv) >= 2 and (sys.argv[1] == '-h' or sys.argv[1] == '--help'): | ||
print_usage() | ||
exit(0) | ||
if not is_tool_present('nm'): | ||
print('ERROR: Cannot find nm executable, please install nm') | ||
exit(1) | ||
if len(sys.argv) == 3: | ||
binary_path = sys.argv[1] | ||
a_path = sys.argv[2] | ||
run_analysis(binary_path, a_path) | ||
if len(sys.argv) == 2: | ||
binary_path = sys.argv[1] | ||
a_path = './bonus/authorized_functions.txt' | ||
run_analysis(binary_path, a_path) | ||
print_usage() | ||
exit(1) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/python3 | ||
import os | ||
from sys import argv | ||
|
||
if __name__ == "__main__": | ||
if len(argv) == 2: | ||
file_content = argv[1].split(",") | ||
for file in file_content: | ||
if not os.path.exists(file): | ||
print("::error file=" + file + "::File not found") | ||
exit(1) | ||
if not os.access(file, os.X_OK): | ||
print("::error file=" + file + "::File is not executable") | ||
exit(1) | ||
print("::notice title=Program compilation::All programs was compiled successfully") | ||
exit(0) | ||
else: | ||
print("::notice title=Program compilation::All programs was compiled successfully") | ||
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/python3 | ||
|
||
if __name__ == "__main__": | ||
with open("coding-style-reports.log", "r") as f: | ||
file_content = f.readlines() | ||
find = False | ||
if len(file_content) > 0: | ||
for line in file_content: | ||
content = line.split(":") | ||
if len(content[2].split(" ")) > 2: | ||
continue | ||
print("::error file=" + content[0] + ",line=" + content[1] + | ||
",title=" + content[2].split(" ")[1] + " coding style error::" + content[3]) | ||
find = True | ||
if find: | ||
exit(1) | ||
else: | ||
print("::notice title=Coding Style::No errors found") | ||
exit(0) | ||
else: | ||
print("::notice title=Coding Style::No errors found") | ||
exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# The files indicated will not be pushed | ||
#.gitignore | ||
|
||
# Temporary files | ||
./temp | ||
./tmp | ||
*~ | ||
'#*#' | ||
.#* | ||
|
||
# Coding-style-checker files | ||
*.log | ||
|
||
# C compiled files or output files and lib | ||
*.o | ||
*.a | ||
a.out | ||
asm | ||
vm | ||
corewar | ||
libcsfml-graphics.so* | ||
|
||
# Unit_tests files | ||
*.gcda | ||
*.gcno | ||
*.gcov | ||
unit_tests | ||
|
||
# Valgrind files | ||
vgcore.* | ||
|
||
# Software folders | ||
.vscode | ||
.idea | ||
|
||
# Project informations files | ||
|
||
# Testing files | ||
foo.txt | ||
|
||
# Backup files | ||
*.old | ||
|
||
# Documentation files |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.