mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-02-15 20:02:44 +00:00
Compare commits
7 Commits
dependabot
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2d77faa6c | ||
|
|
c2a423714f | ||
|
|
d86114fa22 | ||
|
|
0c0cfe2c86 | ||
|
|
3602f343ac | ||
|
|
f46e379b8d | ||
|
|
e278381eca |
@@ -73,7 +73,7 @@ In double-anonymous peer-review, the boundary of anonymization is the paper plus
|
||||
|
||||
## How does it work?
|
||||
|
||||
Anonymous Github either download the complete repository and anonymize the content of the file or proxy the request to GitHub. In both case, the original and anonymized versions of the file are cached on the server.
|
||||
Anonymous Github either downloads the complete repository and anonymizes the content of the file or proxies the request to GitHub. In both cases, the original and anonymized versions of the file are cached on the server.
|
||||
|
||||
## Related tools
|
||||
|
||||
|
||||
10998
package-lock.json
generated
10998
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
"unknown_error": "Unknown error, contact the admin.",
|
||||
"unreachable": "Anonymous GitHub is unreachable, contact the admin.",
|
||||
"request_error": "Unable to download the file, check your connection or contact the admin.",
|
||||
"repo_access_limited": "Access to repository limited by org.",
|
||||
"repo_not_found": "The repository is not found.",
|
||||
"repo_not_accessible": "Anonymous GitHub is unable to or is forbidden to access the repository.",
|
||||
"repository_expired": "The repository is expired",
|
||||
|
||||
@@ -13,42 +13,6 @@
|
||||
role="tablist"
|
||||
aria-multiselectable="true"
|
||||
>
|
||||
<div class="panel panel-default mb-4">
|
||||
<div class="panel-heading p-3" role="tab" id="heading0">
|
||||
<h3 class="panel-title">
|
||||
<a
|
||||
class="collapsed"
|
||||
role="button"
|
||||
title=""
|
||||
data-toggle="collapse"
|
||||
data-parent="#faq"
|
||||
href="#download"
|
||||
aria-expanded="true"
|
||||
aria-controls="download"
|
||||
>
|
||||
Can I download the repository?
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
id="download"
|
||||
class="panel-collapse collapse"
|
||||
role="tabpanel"
|
||||
aria-labelledby="heading0"
|
||||
>
|
||||
<div class="panel-body p-3">
|
||||
<p>
|
||||
It is currently not possible to download an anonymized
|
||||
repository neither to clone it.
|
||||
It is technically possible to implement however it
|
||||
would require additional processing power and storage.
|
||||
I am currently not able to cover the cost of this feature.
|
||||
If you want to see this feature on Anonymous GitHub, please consider doing a donation.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default mb-4">
|
||||
<div class="panel-heading p-3" role="tab" id="heading6">
|
||||
<h3 class="panel-title">
|
||||
@@ -75,9 +39,6 @@
|
||||
<div class="panel-body p-3">
|
||||
<p>
|
||||
<ul>
|
||||
<li>
|
||||
Anonymous GitHub does not allow to download the repository.
|
||||
</li>
|
||||
<li>
|
||||
Anonymous GitHub only anonymizes textual files.
|
||||
It does not support the use of a static site generator, such as Jekyll, with GitHub Pages (although Markdown files are converted to HTML without any special formatting).
|
||||
|
||||
@@ -28,18 +28,19 @@ export async function checkToken(token: string) {
|
||||
export async function getToken(repository: Repository) {
|
||||
const span = trace.getTracer("ano-file").startSpan("GHUtils.getToken");
|
||||
span.setAttribute("repoId", repository.repoId);
|
||||
console.log("getToken", repository.repoId);
|
||||
try {
|
||||
if (repository.model.source.accessToken) {
|
||||
// only check the token if the repo has been visited less than 10 minutes ago
|
||||
if (
|
||||
repository.status == RepositoryStatus.READY &&
|
||||
repository.model.lastView > new Date(Date.now() - 1000 * 60 * 10)
|
||||
) {
|
||||
return repository.model.source.accessToken;
|
||||
} else if (await checkToken(repository.model.source.accessToken)) {
|
||||
return repository.model.source.accessToken;
|
||||
}
|
||||
}
|
||||
// if (repository.model.source.accessToken) {
|
||||
// // only check the token if the repo has been visited less than 10 minutes ago
|
||||
// if (
|
||||
// repository.status == RepositoryStatus.READY &&
|
||||
// repository.model.lastView > new Date(Date.now() - 1000 * 60 * 10)
|
||||
// ) {
|
||||
// return repository.model.source.accessToken;
|
||||
// } else if (await checkToken(repository.model.source.accessToken)) {
|
||||
// return repository.model.source.accessToken;
|
||||
// }
|
||||
// }
|
||||
if (!repository.owner.model.accessTokens?.github) {
|
||||
const query = await UserModel.findById(repository.owner.id, {
|
||||
accessTokens: 1,
|
||||
|
||||
@@ -272,6 +272,21 @@ export async function getRepositoryFromGitHub(opt: {
|
||||
).data;
|
||||
} catch (error) {
|
||||
span.recordException(error as Error);
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message.includes(
|
||||
"organization has enabled OAuth App access restrictions"
|
||||
)
|
||||
) {
|
||||
throw new AnonymousError("repo_access_limited", {
|
||||
httpStatus: 403,
|
||||
object: {
|
||||
owner: opt.owner,
|
||||
repo: opt.repo,
|
||||
},
|
||||
cause: error as Error,
|
||||
});
|
||||
}
|
||||
throw new AnonymousError("repo_not_found", {
|
||||
httpStatus: (error as any).status,
|
||||
object: {
|
||||
|
||||
@@ -10,6 +10,7 @@ import config from "../../config";
|
||||
import UserModel from "../../core/model/users/users.model";
|
||||
import { IUserDocument } from "../../core/model/users/users.types";
|
||||
import AnonymousError from "../../core/AnonymousError";
|
||||
import AnonymizedPullRequestModel from "../../core/model/anonymizedPullRequests/anonymizedPullRequests.model";
|
||||
|
||||
export function ensureAuthenticated(
|
||||
req: express.Request,
|
||||
@@ -33,6 +34,10 @@ const verify = async (
|
||||
user = await UserModel.findOne({ "externalIDs.github": profile.id });
|
||||
if (user) {
|
||||
user.accessTokens.github = accessToken;
|
||||
await AnonymizedPullRequestModel.updateMany(
|
||||
{ owner: user._id },
|
||||
{ "source.accessToken": accessToken }
|
||||
);
|
||||
} else {
|
||||
const photo = profile.photos ? profile.photos[0]?.value : null;
|
||||
user = new UserModel({
|
||||
|
||||
Reference in New Issue
Block a user