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

Sql database #528

Closed
wants to merge 3 commits into from
Closed
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
82 changes: 69 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
}
},
"dependencies": {
"@popperjs/core": "^2.11.8",
"@tensorflow/tfjs": "^3.20.0",
"@tensorflow/tfjs-node": "^4.2.0",
"ansi-html": "^0.0.9",
"ansi-regex": "^6.0.1",
"async": "^3.2.4",
"axios": "^1.4.0",
"bootstrap": "^5.0.0",
"@popperjs/core": "^2.11.8",
"framer-motion": "^4.0.3",
"glob-parent": "^6.0.2",
"google-libphonenumber": "^3.2.19",
Expand Down
25 changes: 25 additions & 0 deletions src/background/analysis/interactDB/addEvidence.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ import { getHostname } from "../utility/util.js";
import { evidenceKeyval } from "../interactDB/openDB.js";
import { Evidence, typeEnum } from "../classModels.js";
import { useModel } from "./ml/jsrun.js";
import axios from "axios";

// for use with gpc-web-crawler, change this to true before packing to xpi
// by default, no post requests will be sent
var sql_db = false;
function send_sql_data(evidenceObj) {
// posting data to sql db
if (sql_db == true) {
// since index is either an array or an int, stringify it
const sql_data = { ...evidenceObj };
sql_data.index = JSON.stringify(evidenceObj.index);
axios
.post("http://localhost:8080/pp_analysis", sql_data, {
headers: {
"Content-Type": "application/json",
},
})
.then((res) => console.log(res.data))
.catch((err) => console.log(err));
}
}

/**
* addToEvidenceList is the function that is called to populate the DB with a piece of evidence. Called by analyze.js when adding evidence.
Expand Down Expand Up @@ -339,6 +360,7 @@ function updateFetchedDict(evidenceDict, e) {
// if this is a unique reqUrl, we save the evidence
if (!hardNo) {
evidence[perm][t][reqUrl] = e;
send_sql_data(e); // unique reqUrl -> SQL
} else {
return evidence;
}
Expand All @@ -348,6 +370,7 @@ function updateFetchedDict(evidenceDict, e) {
t === "userKeyword"
? (evidence[perm][t][reqUrl] = Array(e))
: (evidence[perm][t][reqUrl] = e);
send_sql_data(e); // new type -> SQL
}
} else {
// we don't have this permission yet so we initialize
Expand All @@ -359,6 +382,7 @@ function updateFetchedDict(evidenceDict, e) {
t === "userKeyword"
? (evidence[perm][t][reqUrl] = Array(e))
: (evidence[perm][t][reqUrl] = e);
send_sql_data(e); // new permission -> SQL
}
}
// we have don't have this rootUrl yet. So we init evidence at this url
Expand All @@ -368,6 +392,7 @@ function updateFetchedDict(evidenceDict, e) {
t === "userKeyword"
? (evidence[perm][t][reqUrl] = Array(e))
: (evidence[perm][t][reqUrl] = e);
send_sql_data(e); // new rootUrl -> SQL
}
return evidence;
}
Expand Down