piliguori commited on
Commit
6e7eaf3
·
verified ·
1 Parent(s): ee15785

Upload 3316 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. Appendix.pdf +0 -0
  3. NOTICE.txt +29 -0
  4. code_test/01_code.py +13 -0
  5. code_test/02_code.py +11 -0
  6. code_test/03_code.py +10 -0
  7. convert_to_LF.py +23 -0
  8. extension_PatchitPy/.eslintrc.json +25 -0
  9. extension_PatchitPy/.vscode-test.mjs +5 -0
  10. extension_PatchitPy/.vscode/extensions.json +8 -0
  11. extension_PatchitPy/.vscode/launch.json +17 -0
  12. extension_PatchitPy/.vscodeignore +10 -0
  13. extension_PatchitPy/CHANGELOG.md +9 -0
  14. extension_PatchitPy/extension.js +36 -0
  15. extension_PatchitPy/jsconfig.json +13 -0
  16. extension_PatchitPy/launch_tool/patchitpy_ext.sh +121 -0
  17. extension_PatchitPy/launch_tool/patchitpy_starter.sh +39 -0
  18. extension_PatchitPy/launch_tool/script_py/convertInline.py +33 -0
  19. extension_PatchitPy/launch_tool/script_py/convert_json_to_txt.py +39 -0
  20. extension_PatchitPy/launch_tool/script_py/convert_json_wo_keys.py +28 -0
  21. extension_PatchitPy/launch_tool/script_py/preprocessing.py +34 -0
  22. extension_PatchitPy/launch_tool/script_py/preprocessing_macos.py +35 -0
  23. extension_PatchitPy/launch_tool/script_py/preprocessingcopy.py +34 -0
  24. extension_PatchitPy/launch_tool/tool_derem_ext.sh +0 -0
  25. extension_PatchitPy/node_modules/.DS_Store +0 -0
  26. extension_PatchitPy/node_modules/.bin/_mocha +3 -0
  27. extension_PatchitPy/node_modules/.bin/_mocha.cmd +3 -0
  28. extension_PatchitPy/node_modules/.bin/_mocha.ps1 +3 -0
  29. extension_PatchitPy/node_modules/.bin/acorn +3 -0
  30. extension_PatchitPy/node_modules/.bin/acorn.cmd +3 -0
  31. extension_PatchitPy/node_modules/.bin/acorn.ps1 +3 -0
  32. extension_PatchitPy/node_modules/.bin/c8 +3 -0
  33. extension_PatchitPy/node_modules/.bin/c8.cmd +3 -0
  34. extension_PatchitPy/node_modules/.bin/c8.ps1 +3 -0
  35. extension_PatchitPy/node_modules/.bin/eslint +3 -0
  36. extension_PatchitPy/node_modules/.bin/eslint.cmd +3 -0
  37. extension_PatchitPy/node_modules/.bin/eslint.ps1 +3 -0
  38. extension_PatchitPy/node_modules/.bin/flat +3 -0
  39. extension_PatchitPy/node_modules/.bin/flat.cmd +3 -0
  40. extension_PatchitPy/node_modules/.bin/flat.ps1 +3 -0
  41. extension_PatchitPy/node_modules/.bin/glob +3 -0
  42. extension_PatchitPy/node_modules/.bin/glob.cmd +3 -0
  43. extension_PatchitPy/node_modules/.bin/glob.ps1 +3 -0
  44. extension_PatchitPy/node_modules/.bin/he +3 -0
  45. extension_PatchitPy/node_modules/.bin/he.cmd +3 -0
  46. extension_PatchitPy/node_modules/.bin/he.ps1 +3 -0
  47. extension_PatchitPy/node_modules/.bin/js-yaml +3 -0
  48. extension_PatchitPy/node_modules/.bin/js-yaml.cmd +3 -0
  49. extension_PatchitPy/node_modules/.bin/js-yaml.ps1 +3 -0
  50. extension_PatchitPy/node_modules/.bin/mocha +3 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ img/NEW_RunExtension1.png filter=lfs diff=lfs merge=lfs -text
37
+ img/NEW_RunExtension4.png filter=lfs diff=lfs merge=lfs -text
Appendix.pdf ADDED
Binary file (73 kB). View file
 
NOTICE.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ PatchitPy
2
+ Copyright (c) 2025
3
+ Francesco Altiero, Domenico Cotroneo, Roberta De Luca, Pietro Liguori
4
+
5
+ This project is distributed under the terms of the
6
+ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0).
7
+
8
+ You are free to share and adapt this work under the following conditions:
9
+ - Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
10
+ - NonCommercial — You may not use the material for commercial purposes.
11
+ - ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license.
12
+
13
+ For the full license text, see:
14
+ https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
15
+
16
+ Authors:
17
+ - Francesco Altiero (franc.altiero@studenti.unina.it), Università degli Studi di Napoli Federico II
18
+ - Domenico Cotroneo (cotrone@unina.it), Università degli Studi di Napoli Federico II
19
+ - Roberta De Luca (roberta.deluca2@unina.it), Università degli Studi di Napoli Federico II
20
+ - Pietro Liguori (pietro.liguori@unina.it), Università degli Studi di Napoli Federico II
21
+
22
+ Paper:
23
+ "Securing AI Code Generation Through Automated Pattern-Based Patching"
24
+ 2025 55th Annual IEEE/IFIP International Conference on Dependable Systems and Networks Workshops (DSN-W)
25
+ Naples, Italy, 2025, pp. 282-289
26
+ DOI: https://doi.org/10.1109/DSN-W65791.2025.00077
27
+
28
+
29
+ If you use this tool in academic work, please cite us.
code_test/01_code.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ def load_yaml(yaml_payload):
4
+ '''
5
+ Write a Python code that defines a YAML payload from a request,
6
+ loads this payload into a dictionary called prod_and_qt by using a function for loading
7
+ '''
8
+ prod_and_qt = yaml.load(yaml_payload)
9
+ return prod_and_qt
10
+
11
+ yaml_payload = ""
12
+ prod_and_qt = load_yaml(yaml_payload)
13
+ print(prod_and_qt)
code_test/02_code.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, make_response
2
+ app = Flask(__name__)
3
+
4
+ @app.route("/profile")
5
+ def profile():
6
+ '''
7
+ Get the username from the request, make a response with it and return it
8
+ '''
9
+ username = request.args.get('username')
10
+ response = make_response(f"Hello {username}")
11
+ return response
code_test/03_code.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask
2
+
3
+ app = Flask(__name__)
4
+
5
+ @app.route('/')
6
+ def home():
7
+ return 'Hello, Flask for Academic Purposes!'
8
+
9
+ if __name__ == '__main__':
10
+ app.run(debug=True)
convert_to_LF.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import sys
4
+
5
+ def check_dos2unix():
6
+ """Verify if dos2unix is installed"""
7
+ if subprocess.call(["which", "dos2unix"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) != 0:
8
+ print("Error: dos2unix not installed. Install it with 'sudo apt update && sudo apt install dos2unix'")
9
+ sys.exit(1)
10
+
11
+ def convert_files_to_lf(start_dir=".."):
12
+ """Search for all .sh files into the folder and convert them using dos2unix."""
13
+ for root, dirs, files in os.walk(start_dir):
14
+ for file in files:
15
+ if file.endswith(".sh"):
16
+ filepath = os.path.join(root, file)
17
+ subprocess.run(["dos2unix", filepath], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
18
+ print(f"Convertited: {file}")
19
+ print("\033[92mConversion complete! Every .sh file is in the LF format.\033[0m")
20
+
21
+ if __name__ == "__main__":
22
+ check_dos2unix()
23
+ convert_files_to_lf()
extension_PatchitPy/.eslintrc.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "env": {
3
+ "browser": false,
4
+ "commonjs": true,
5
+ "es6": true,
6
+ "node": true,
7
+ "mocha": true
8
+ },
9
+ "parserOptions": {
10
+ "ecmaVersion": 2018,
11
+ "ecmaFeatures": {
12
+ "jsx": true
13
+ },
14
+ "sourceType": "module"
15
+ },
16
+ "rules": {
17
+ "no-const-assign": "warn",
18
+ "no-this-before-super": "warn",
19
+ "no-undef": "warn",
20
+ "no-unreachable": "warn",
21
+ "no-unused-vars": "warn",
22
+ "constructor-super": "warn",
23
+ "valid-typeof": "warn"
24
+ }
25
+ }
extension_PatchitPy/.vscode-test.mjs ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import { defineConfig } from '@vscode/test-cli';
2
+
3
+ export default defineConfig({
4
+ files: 'test/**/*.test.js',
5
+ });
extension_PatchitPy/.vscode/extensions.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
3
+ // for the documentation about the extensions.json format
4
+ "recommendations": [
5
+ "dbaeumer.vscode-eslint",
6
+ "ms-vscode.extension-test-runner"
7
+ ]
8
+ }
extension_PatchitPy/.vscode/launch.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // A launch configuration that launches the extension inside a new window
2
+ // Use IntelliSense to learn about possible attributes.
3
+ // Hover to view descriptions of existing attributes.
4
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
+ {
6
+ "version": "0.2.0",
7
+ "configurations": [
8
+ {
9
+ "name": "Run Extension",
10
+ "type": "extensionHost",
11
+ "request": "launch",
12
+ "args": [
13
+ "--extensionDevelopmentPath=${workspaceFolder}"
14
+ ]
15
+ }
16
+ ]
17
+ }
extension_PatchitPy/.vscodeignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .vscode/**
2
+ .vscode-test/**
3
+ test/**
4
+ .gitignore
5
+ .yarnrc
6
+ vsc-extension-quickstart.md
7
+ **/jsconfig.json
8
+ **/*.map
9
+ **/.eslintrc.json
10
+ **/.vscode-test.*
extension_PatchitPy/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Change Log
2
+
3
+ All notable changes to the "devaic" extension will be documented in this file.
4
+
5
+ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6
+
7
+ ## [Unreleased]
8
+
9
+ - Initial release
extension_PatchitPy/extension.js ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // The module 'vscode' contains the VS Code extensibility API
2
+ // Import the module and reference it with the alias vscode in your code below
3
+ const vscode = require('vscode');
4
+ const runPatchitpyFromText = require('./src/RunPatchitpyFromText');
5
+
6
+
7
+
8
+
9
+ // This method is called when your extension is activated
10
+ // Your extension is activated the very first time the command is executed
11
+
12
+ /**
13
+ * @param {vscode.ExtensionContext} context
14
+ */
15
+ function activate(context) {
16
+
17
+ // Use the console to output diagnostic information (console.log) and errors (console.error)
18
+ // This line of code will only be executed once when your extension is activated
19
+ console.log('tool is now active!');
20
+
21
+ // The command has been defined in the package.json file
22
+ // Now provide the implementation of the command with registerCommand
23
+ // The commandId parameter must match the command field in package.json
24
+ let disposable1 = vscode.commands.registerCommand('patchitpy.runPatchitpyText', ()=> {
25
+ runPatchitpyFromText();
26
+ });
27
+ context.subscriptions.push(disposable1);
28
+ }
29
+
30
+ // This method is called when your extension is deactivated
31
+ function deactivate() {}
32
+
33
+ module.exports = {
34
+ activate,
35
+ deactivate
36
+ }
extension_PatchitPy/jsconfig.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "module": "Node16",
4
+ "target": "ES2022",
5
+ "checkJs": true, /* Typecheck .js files. */
6
+ "lib": [
7
+ "ES2022"
8
+ ]
9
+ },
10
+ "exclude": [
11
+ "node_modules"
12
+ ]
13
+ }
extension_PatchitPy/launch_tool/patchitpy_ext.sh ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+
4
+
5
+ # ---------- SET SRC DIRECTORY ----------
6
+ # Check input argument
7
+ if [ -z "$1" ]; then
8
+ echo "Usage: $0 <path1>"
9
+ exit 1
10
+ fi
11
+ if [ -z "$2" ]; then
12
+ echo "Usage: $0 $1 <path2>"
13
+ exit 1
14
+ fi
15
+
16
+ # Extract file name
17
+ filename=$(basename "$1")
18
+ nameWithoutType=$(echo "$filename" | awk -F '.' '{print $1}')
19
+
20
+ # Extract the path
21
+ SRC_DIR=$(dirname "$1")
22
+
23
+ # Set installation path of the tool
24
+ TOOL_DIR="$2"
25
+
26
+ RES_DIR="$SRC_DIR/results_$nameWithoutType"
27
+
28
+ SCRIPT_DIR="$TOOL_DIR/script_py"
29
+ GEN_DIR="$TOOL_DIR/generated_file"
30
+
31
+ PATH_1="/opt/homebrew/opt/grep/libexec/gnubin"
32
+ PATH_2="/usr/local/opt/grep/libexec/gnubin"
33
+
34
+ name_os=$(uname)
35
+ timestamp=$(date +"%Y-%m-%d_%H-%M-%S")
36
+
37
+ # ---------- CREATE RESULTS DIRECTORIES ----------
38
+ dirs=("$RES_DIR")
39
+ for dir in "${dirs[@]}"; do
40
+ # Crea la cartella, incluso il percorso intermedio
41
+ mkdir -p "$dir"
42
+ if [ $? -eq 0 ]; then
43
+ echo "Created directory: $dir"
44
+ else
45
+ echo "Failed to create directory: $dir"
46
+ fi
47
+ done
48
+
49
+ echo "$1" | grep -q "/"
50
+ if [ $? -eq 0 ]; then
51
+ new_name="$filename"
52
+ else
53
+ new_name="$1"
54
+ fi
55
+
56
+ filename_res="[$timestamp]_$new_name"
57
+ type=$(echo "$filename_res" | awk -F '.' '{print $2}')
58
+
59
+ echo "$1" | grep -q ".txt"
60
+ if [ $? -eq 1 ]; then
61
+ filename_res=$(echo "$filename_res" | sed "s/.$type/.txt/g")
62
+ fi
63
+
64
+ # Define the names of the generated files
65
+ rem_file="REM_$filename_res"
66
+ input_file="INPUT_$filename_res"
67
+ tmp_file="MOD_INPUT_$filename_res"
68
+
69
+ # Define the paths of the generated files
70
+ rem_path="$RES_DIR/$rem_file"
71
+ input_path="$GEN_DIR/$input_file"
72
+ tmp_path="$GEN_DIR/$tmp_file"
73
+
74
+ # ---------- CONVERTING JSON TO TXT ----------
75
+ if [ "$type" == "json" ]; then
76
+ cat "$1" | grep -q "\"code\":"
77
+ if [ $? -eq 0 ]; then
78
+ python3 "$SCRIPT_DIR/convert_json_to_txt.py" "$1" "$tmp_path"
79
+ else
80
+ python3 "$SCRIPT_DIR/convert_json_wo_keys.py" "$1" "$tmp_path"
81
+ fi
82
+ fi
83
+
84
+ # ---------- SETUP ----------
85
+ if [ "$name_os" = "Darwin" ]; then # MAC-OS system
86
+
87
+ ls "$PATH_1" > /dev/null 2>&1
88
+ if [ $? -eq 0 ]; then # If the path already exists, it is not exported
89
+ echo "$PATH" | grep -q "$PATH_1"
90
+ if [ $? -eq 1 ]; then
91
+ export "PATH=$PATH_1:$PATH"
92
+ fi
93
+ else
94
+ ls "$PATH_2" > /dev/null 2>&1
95
+ if [ $? -eq 0 ]; then # If the path already exists, it is not exported
96
+ echo "$PATH" | grep -q "$PATH_2"
97
+ if [ $? -eq 1 ]; then
98
+ export "PATH=$PATH_2:$PATH"
99
+ fi
100
+ fi
101
+ fi
102
+ if [ "$type" == "json" ]; then
103
+ python3 "$SCRIPT_DIR/preprocessing_macos.py" "$tmp_path" "$input_path"
104
+ rm "$tmp_path"
105
+ elif [ "$type" == "txt" ]; then
106
+ python3 "$SCRIPT_DIR/preprocessing_macos.py" "$1" "$input_path"
107
+ fi
108
+
109
+ elif [ "$name_os" = "Linux" ]; then # LINUX system
110
+ if [ "$type" == "json" ]; then
111
+ python3 "$SCRIPT_DIR/preprocessing.py" "$tmp_path" "$input_path"
112
+ rm "$tmp_path"
113
+ elif [ "$type" == "txt" ]; then
114
+ python3 "$SCRIPT_DIR/preprocessing.py" "$1" "$input_path"
115
+ fi
116
+ fi
117
+
118
+ # ---------- LAUNCHING THE TOOL ----------
119
+ echo -e "[***] Vulnerability Scanning ...\n"
120
+
121
+ bash "$TOOL_DIR/tool_derem_ext.sh" "$input_path" "$rem_path" 2> /dev/null
extension_PatchitPy/launch_tool/patchitpy_starter.sh ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Check input argument $1 and $2
3
+ if [ -z "$1" ]; then
4
+ echo "Usage: $0 <path1>"
5
+ exit 1
6
+ fi
7
+ if [ -z "$2" ]; then
8
+ echo "Usage: $0 $1 <path2>"
9
+ exit 1
10
+ fi
11
+
12
+ echo "STARTING TOOL"
13
+
14
+ # Extract file name
15
+ filename=$(basename "$1")
16
+ nameWithoutType=$(echo "$filename" | awk -F '.' '{print $1}')
17
+
18
+ # Extract the path
19
+ SRC_DIR=$(dirname "$1")
20
+
21
+ txtFile="$nameWithoutType.txt"
22
+ txtFilePath="$SRC_DIR/$txtFile"
23
+
24
+ # Set installation path of the tool
25
+ TOOL_DIR="$2"
26
+ SCRIPT_DIR="$TOOL_DIR/script_py"
27
+ PATCHITPY_SCRIPT_PATH="$TOOL_DIR/patchitpy_ext.sh"
28
+
29
+ echo "PATCHITPY_SCRIPT_PATH: $TOOL_DIR"
30
+
31
+ # Ensure paths with spaces are handled by wrapping them in quotes
32
+ python3 "$SCRIPT_DIR/convertInline.py" "$1" "$txtFilePath"
33
+ bash "$PATCHITPY_SCRIPT_PATH" "$txtFilePath" "$TOOL_DIR"
34
+
35
+ # Clean up
36
+ echo "Cleaning up..."
37
+ rm -f "$txtFilePath"
38
+ rm -f "$TOOL_DIR/generated_file"/*.txt
39
+
extension_PatchitPy/launch_tool/script_py/convertInline.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import sys
3
+ import os
4
+
5
+ def convert_to_single_line(input_file, output_file):
6
+ try:
7
+ #controlla se il file esiste
8
+ if not os.path.exists(input_file):
9
+ print(f"Il file '{input_file}' non esiste.")
10
+ return
11
+
12
+ # Legge il contenuto del file sorgente
13
+ with open(input_file, 'r', encoding='utf-8') as file:
14
+ content = file.read()
15
+
16
+ # Rimuove i caratteri di nuova riga
17
+ single_line_content = content.replace("\n","\\n ")
18
+
19
+ # Salva il contenuto risultante in un nuovo file
20
+ with open(output_file, 'w', encoding='utf-8') as file:
21
+ file.write(single_line_content)
22
+
23
+ print(f"File convertito con successo e salvato in {output_file}")
24
+ except Exception as e:
25
+ print(f"Si è verificato un errore: {e}")
26
+
27
+
28
+ # Esempio di utilizzo
29
+ source_file = sys.argv[1] # Inserisci il nome del file sorgente
30
+
31
+ target_file = sys.argv[2] # Inserisci il nome del file di destinazione
32
+
33
+ convert_to_single_line(source_file, target_file)
extension_PatchitPy/launch_tool/script_py/convert_json_to_txt.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import sys
3
+
4
+ print("[***] Json to txt convertion...")
5
+
6
+ input_file = sys.argv[1]
7
+ file=json.load(open(input_file))
8
+
9
+ output_file = sys.argv[2]
10
+
11
+ data=list()
12
+
13
+ for i in range(len(file)):
14
+ diz=dict()
15
+ diz={
16
+ "code": str
17
+ }
18
+ diz["code"]=file[i]["code"]
19
+ data.append(diz)
20
+
21
+
22
+ #write json
23
+ with open(output_file,'w') as outfile:
24
+ json.dump(data,outfile, indent=0, separators=(',',':'))
25
+
26
+ data=list()
27
+
28
+ for i, line in enumerate(open(output_file)):
29
+ new_line=line.replace("\"code\":\"","")
30
+ new_line=new_line.replace("\"\n","\n")
31
+ new_line=new_line.replace("{\n","")
32
+ new_line=new_line.replace("},\n","")
33
+ new_line=new_line.replace("}\n","")
34
+ if i != 0 and line != "]":
35
+ data.append(new_line)
36
+
37
+
38
+ with open(output_file, 'w') as f:
39
+ f.writelines(data)
extension_PatchitPy/launch_tool/script_py/convert_json_wo_keys.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ print("[***] Json to txt convertion...")
4
+
5
+ input_file = sys.argv[1]
6
+
7
+ output_file = sys.argv[2]
8
+
9
+
10
+ data=list()
11
+
12
+ for i, line in enumerate(open(input_file)):
13
+ if line.strip():
14
+ new_line = line.strip()
15
+ new_line=new_line[1:]
16
+ new_line=new_line.replace("\",","\n")
17
+ new_line=new_line.replace("\\n","n")
18
+ if i != 0:
19
+ data.append(new_line)
20
+ else:
21
+ data.append(new_line)
22
+
23
+
24
+ data.append("\n")
25
+
26
+
27
+ with open(output_file, 'w') as f:
28
+ f.writelines(data)
extension_PatchitPy/launch_tool/script_py/preprocessing.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ print("[***] Processing data...")
4
+
5
+ input_file = sys.argv[1]
6
+
7
+ output_file = sys.argv[2]
8
+
9
+ data=list()
10
+
11
+ for i, line in enumerate(open(input_file)):
12
+ if line.strip():
13
+ new_line=line.replace("\",\n","\n")
14
+ new_line=new_line.replace("\"\n","\n")
15
+ new_line=new_line.replace("\\\"","'")
16
+ new_line=new_line.replace("request.form [","request.form[")
17
+ new_line=new_line.replace("request.files [","request.files[")
18
+ new_line=new_line.replace("request.args [","request.args[")
19
+ new_line=new_line.replace(" ''","\\\"")
20
+ new_line=new_line.replace("*","PRODUCT_SYMBOL")
21
+ new_line=new_line.replace("[\\\" ","[\\\"")
22
+ new_line=new_line.replace("(\\\" ","(\\\"")
23
+ new_line=new_line.replace(", \\\" ",", \\\"")
24
+ new_line=new_line.replace(" \']","\']")
25
+ new_line=new_line.replace("request.args.get [","request.args.get[")
26
+ new_line=new_line.replace("session [","session[")
27
+
28
+ data.append(new_line)
29
+
30
+
31
+ data.append("\n")
32
+
33
+ with open(output_file, 'w') as f:
34
+ f.writelines(data)
extension_PatchitPy/launch_tool/script_py/preprocessing_macos.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ print("[***] Processing data...")
4
+
5
+ input_file = sys.argv[1]
6
+
7
+ output_file = sys.argv[2]
8
+
9
+ data=list()
10
+
11
+ for i, line in enumerate(open(input_file)):
12
+ if line.strip():
13
+ new_line=line.replace("\",\n","\n")
14
+ new_line=new_line.replace("\"\n","\n")
15
+ new_line=new_line.replace("\\\"","'")
16
+ new_line=new_line.replace("request.form [","request.form[")
17
+ new_line=new_line.replace("request.files [","request.files[")
18
+ new_line=new_line.replace("request.args [","request.args[")
19
+ new_line=new_line.replace(" ''","\\\"")
20
+ new_line=new_line.replace("*","PRODUCT_SYMBOL")
21
+ new_line=new_line.replace("[\\\" ","[\\\"")
22
+ new_line=new_line.replace("(\\\" ","(\\\"")
23
+ new_line=new_line.replace(", \\\" ",", \\\"")
24
+ new_line=new_line.replace(" \']","\']")
25
+ new_line=new_line.replace("request.args.get [","request.args.get[")
26
+ new_line=new_line.replace("session [","session[")
27
+ new_line=new_line.replace("\\n","\\\\\\n")
28
+
29
+ data.append(new_line)
30
+
31
+ data.append("\n")
32
+
33
+ with open(output_file, 'w') as f:
34
+ f.writelines(data)
35
+
extension_PatchitPy/launch_tool/script_py/preprocessingcopy.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+
3
+ print("[***] Processing data...")
4
+
5
+ input_file = sys.argv[1]
6
+
7
+ output_file = sys.argv[2]
8
+
9
+ data=list()
10
+
11
+ for i, line in enumerate(open(input_file)):
12
+ if line.strip():
13
+ new_line=line.replace("\",\n","\n")
14
+ new_line=new_line.replace("\"\n","\n")
15
+ new_line=new_line.replace("\\\"","'")
16
+ new_line=new_line.replace("request.form [","request.form[")
17
+ new_line=new_line.replace("request.files [","request.files[")
18
+ new_line=new_line.replace("request.args [","request.args[")
19
+ new_line=new_line.replace(" ''","\\\"")
20
+ new_line=new_line.replace("*","PRODUCT_SYMBOL")
21
+ new_line=new_line.replace("[\\\" ","[\\\"")
22
+ new_line=new_line.replace("(\\\" ","(\\\"")
23
+ new_line=new_line.replace(", \\\" ",", \\\"")
24
+ new_line=new_line.replace(" \']","\']")
25
+ new_line=new_line.replace("request.args.get [","request.args.get[")
26
+ new_line=new_line.replace("session [","session[")
27
+
28
+ data.append(new_line)
29
+
30
+
31
+ data.append("\n")
32
+
33
+ with open(output_file, 'w') as f:
34
+ f.writelines(data)
extension_PatchitPy/launch_tool/tool_derem_ext.sh ADDED
The diff for this file is too large to render. See raw diff
 
extension_PatchitPy/node_modules/.DS_Store ADDED
Binary file (10.2 kB). View file
 
extension_PatchitPy/node_modules/.bin/_mocha ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9914b5445d23058a3f0211336de554dd1022c3e9b3f66a2b58990b38ff35094d
3
+ size 381
extension_PatchitPy/node_modules/.bin/_mocha.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:434d167b337ad4b549504201fcd462c2299b6658274be7da1c7d2672a73ed889
3
+ size 304
extension_PatchitPy/node_modules/.bin/_mocha.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:491e7e92c31d86b53e264f66490218801ddca757361ff249fcccd50c5a35debc
3
+ size 789
extension_PatchitPy/node_modules/.bin/acorn ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:172abb5575ef74185417e36d1df7384fb27720826054f7337bdf26efc2649526
3
+ size 379
extension_PatchitPy/node_modules/.bin/acorn.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:232982bc6995f41ff12e2971f1eda67f3caf357a35a010228f7f7daef06e4335
3
+ size 303
extension_PatchitPy/node_modules/.bin/acorn.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:264bfc66f8543c5adafaa0e1b01dcc93f94b9480377131c0127c541f53f865f2
3
+ size 785
extension_PatchitPy/node_modules/.bin/c8 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff14dd981457e5ef6fea2275b9670aead1380498cc34be5004990942d3b10f41
3
+ size 373
extension_PatchitPy/node_modules/.bin/c8.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cf694fd9a9105df841fea88167c1e0184e4d4e16819c0b5791293fc8f542760
3
+ size 300
extension_PatchitPy/node_modules/.bin/c8.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33e6ef02097d63745e7a6279e9edc0ef785dd6bb4d046f66398642c11faa7bf2
3
+ size 773
extension_PatchitPy/node_modules/.bin/eslint ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bef8aadf5439c79a20f7029a50e8b70d15af61cb8c2e11cda7f40834da7978b1
3
+ size 389
extension_PatchitPy/node_modules/.bin/eslint.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d2ad22346b17b1f2083a4e7ff87544576fb0ba1d5f1335868896626e757378e
3
+ size 308
extension_PatchitPy/node_modules/.bin/eslint.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba7239d9d7870f8076123193edfb016968b55410cbd3fa3ff929d057ee5cccae
3
+ size 805
extension_PatchitPy/node_modules/.bin/flat ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73a23cf395251a3df9875fff07764bcf168c269837db03d7b0df0184f7fcb774
3
+ size 371
extension_PatchitPy/node_modules/.bin/flat.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:705f4ee287aba1dc3c9d3793b5542637e6e936ef237290b2203a81d09a1e8a6f
3
+ size 299
extension_PatchitPy/node_modules/.bin/flat.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:810e93441daf6c25cab12b5a67e6494972e5e1300bced340a45ba018da39c03e
3
+ size 769
extension_PatchitPy/node_modules/.bin/glob ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:130747a55febb9be265dba4f9089710e9c07ba271991f6b51cc368ab248e6480
3
+ size 391
extension_PatchitPy/node_modules/.bin/glob.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b1d804538e8fcb8575af429882e4db43ee2306e90381897c509739385d5345d
3
+ size 309
extension_PatchitPy/node_modules/.bin/glob.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76d0468f0c2a332cc900218fb3cd3dfff4ba6e836b7cd0d682b298c92b965aeb
3
+ size 809
extension_PatchitPy/node_modules/.bin/he ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:82641a1d5f6762c15d216bbd650e1c1dda76cd66f2115ecf46923ff53c1df091
3
+ size 367
extension_PatchitPy/node_modules/.bin/he.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db3b4dec36436dd1bf94052043f27158225f093e479978d0f24cb6dd9445e99c
3
+ size 297
extension_PatchitPy/node_modules/.bin/he.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b4e73c7ef0a6e0a947e5f79488f0f3eb9dfa663e3d5e1f6349b7582082e9998
3
+ size 761
extension_PatchitPy/node_modules/.bin/js-yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c46b44b3bd9b2331fe4f659e672d453b88bcb3e04b4a214d19f91de0b3891b3e
3
+ size 393
extension_PatchitPy/node_modules/.bin/js-yaml.cmd ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0eaab6ee7fd999a70b1379a03774d8308a557f34f812dab521de1bc05615dc07
3
+ size 310
extension_PatchitPy/node_modules/.bin/js-yaml.ps1 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5a6132c4b32e855a2c1f239b2d69b389320cbd10f890ee5069fe5f550e52882
3
+ size 813
extension_PatchitPy/node_modules/.bin/mocha ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc55310a460500aad312cd2b75a66e7ce5d2689513dbf41817a908969c1dcda2
3
+ size 385