Skip to content

Commit

Permalink
.env support
Browse files Browse the repository at this point in the history
.env support, can be activated in the options
jszip and pako library updated
  • Loading branch information
davtur19 committed Feb 12, 2021
1 parent 1b2574a commit 294a853
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ An extension for checking if .git is exposed in visited websites

## Features
- Check if a .git/.svn/.hg folder exists for each site you visit
- Check if a .env file exists for each site you visit
- You will be notified when a folder is found
- List of exposed sites found
- Download the entire .git folder in zip format, even if the files are not listed on the site
Expand All @@ -21,7 +22,7 @@ More info [here](https://github.com/davtur19/DotGit/blob/b0f589dfd78396990b8d17e
### Note:
- Downloading is an extra feature to DotGit, it is not meant to download large repositories (there are limits to the memory usable by extensions, and DotGit does everything in RAM)
- Changing the download settings is recommended as by default the values are kept low to avoid problems for those who do not have a good connection or a good CPU, however too high values could freeze the browser even on powerful computers
- By default svn and mercurial are disabled, to activate them just go to settings and turn them on
- By default svn, mercurial and dotenv are disabled, to activate them just go to settings and turn them on

## Screenshot
![ScreenShot](https://user-images.githubusercontent.com/13476215/90319561-98ecb100-df39-11ea-876a-cc3c6d762932.png)
Expand Down
38 changes: 37 additions & 1 deletion dotgit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const DEFAULT_OPTIONS = {
"functions": {
"git": true,
"svn": false,
"hg": false
"hg": false,
"env": false
},
"color": "grey",
"max_sites": 100,
Expand Down Expand Up @@ -38,6 +39,9 @@ const HG_MANIFEST_HEADERS = [
"\u0000\u0003\u0000\u0001",
];

const ENV_PATH = "/.env";
const ENV_SEARCH = "^[A-Z_]*=";

const GIT_TREE_HEADER = "tree ";
const GIT_OBJECTS_PATH = "objects/";
const GIT_OBJECTS_SEARCH = "[a-f0-9]{40}";
Expand Down Expand Up @@ -79,6 +83,7 @@ let notification_download;
let check_git;
let check_svn;
let check_hg;
let check_env;
let failed_in_a_row;


Expand Down Expand Up @@ -201,6 +206,29 @@ function checkHg(url, visitedSite) {
});
}

function checkEnv(url, visitedSite) {
let to_check = url + ENV_PATH;
const search = new RegExp(ENV_SEARCH, "gm");

fetch(to_check, {
redirect: "manual"
}).then(function (response) {
if (response.status === 200) {
return response.text();
}
return false;
}).then(function (text) {
if (text !== false && search.test(text) === true) {
// .env found
visitedSite.withExposedGit.push({type: "env", url: url});
chrome.storage.local.set(visitedSite);
setBadge();

notification("Found an exposed .env", to_check);
}
});
}


function startDownload(baseUrl, downloadFinished) {
const downloadedFiles = [];
Expand Down Expand Up @@ -405,6 +433,7 @@ function set_options(options) {
check_git = options.functions.git;
check_svn = options.functions.svn;
check_hg = options.functions.hg;
check_env = options.functions.env;
}


Expand Down Expand Up @@ -459,6 +488,9 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
} else if (request.type === "hg") {
check_hg = request.value;
sendResponse({status: true});
} else if (request.type === "env") {
check_env = request.value;
sendResponse({status: true});
} else if (request.type === "notification_new_git") {
notification_new_git = request.value;
sendResponse({status: true});
Expand Down Expand Up @@ -545,6 +577,10 @@ chrome.storage.local.get(["checked", "withExposedGit", "options"], function (res
checkHg(url, result);
save = true;
}
if (check_env) {
checkEnv(url, result);
save = true;
}
// save only if a check is done
if (save) {
result.checked.push(url);
Expand Down
4 changes: 2 additions & 2 deletions lib/jszip.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/pako_inflate.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "DotGit",
"version": "4.1",
"version": "4.2",
"description": "An extension for checking if .git is exposed in visited websites",
"icons": {
"16": "icons/dotgit-16.png",
Expand Down
8 changes: 8 additions & 0 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
<input type="radio" id="hgOff" name="hg" value="off" checked/>
<label for="hgOff">Off</label>
</div>
<div class="browser-style title-option">
.env
<input type="radio" id="envOn" name="env" value="on"/>
<label for="envOn">On</label>

<input type="radio" id="envOff" name="env" value="off" checked/>
<label for="envOff">Off</label>
</div>
</section>
<section class="option">
<div class="browser-style title-option">
Expand Down
10 changes: 10 additions & 0 deletions options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function set_gui(options) {
document.getElementById("svnOff").checked = !options.functions.svn;
document.getElementById("hgOn").checked = options.functions.hg;
document.getElementById("hgOff").checked = !options.functions.hg;
document.getElementById("envOn").checked = options.functions.env;
document.getElementById("envOff").checked = !options.functions.env;
document.getElementById("max_sites").value = options.max_sites;
document.getElementById("max_connections").value = options.download.max_connections;
document.getElementById("failed_in_a_row").value = options.download.failed_in_a_row;
Expand Down Expand Up @@ -51,6 +53,14 @@ document.addEventListener("DOMContentLoaded", function () {
value: result.options.functions.hg
}, function (response) {
});
} else if (e.target.name === "env") {
result.options.functions.env = (e.target.value === "on");
chrome.storage.local.set(result);
chrome.runtime.sendMessage({
type: e.target.name,
value: result.options.functions.env
}, function (response) {
});
} else if (e.target.id === "color") {
result.options.color = e.target.value;
chrome.storage.local.set(result);
Expand Down
3 changes: 3 additions & 0 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ function addElements(element, array, callback, downloading, max_sites) {
if (callback(array[i].type) === "hg") {
link.setAttribute("href", callback(array[i].url) + "/.hg/");
}
if (callback(array[i].type) === "env") {
link.setAttribute("href", callback(array[i].url) + "/.env");
}
link.innerText = callback(array[i].url);

spanLink.appendChild(link);
Expand Down

0 comments on commit 294a853

Please sign in to comment.