fix/forbidden (#58) #60

Merged
张泊明518370910136 merged 7 commits from fix/forbidden into master 2024-10-18 14:41:10 +08:00
No description provided.
周赵嘉程521432910016 added 4 commits 2024-10-17 15:28:40 +08:00
fix: not ignore gitea
All checks were successful
build / build (push) Successful in 1m3s
build / trigger-build-image (push) Has been skipped
eb0ad570ee
refractor(healthcheck/forbidden): use go-gitignore package
Some checks failed
build / build (push) Failing after 1m3s
build / trigger-build-image (push) Has been skipped
84e168dad6
fix(healthcheck/forbidden): skip .
Some checks failed
build / build (push) Failing after 1m15s
build / trigger-build-image (push) Has been skipped
83b6cb6b2c
fix(healthcheck/forbidden): relative path
Some checks failed
build / build (push) Failing after 1m5s
build / trigger-build-image (push) Has been skipped
build / build (pull_request) Failing after 1m5s
build / trigger-build-image (pull_request) Has been skipped
64cbeef111
Author
Member

#58

#58
周赵嘉程521432910016 requested review from 张泊明518370910136 2024-10-17 16:03:33 +08:00
张泊明518370910136 was assigned by 周赵嘉程521432910016 2024-10-17 16:03:41 +08:00
汪睿522370910169 was assigned by 周赵嘉程521432910016 2024-10-17 16:03:41 +08:00
周赵嘉程521432910016 self-assigned this 2024-10-17 16:03:44 +08:00
Author
Member

should fix issue in https://focs.ji.sjtu.edu.cn/git/engr151-24fa/hteam-05

❯ ../JOJ3/build/healthcheck -root=.
### Forbidden File Check Failed:
The following forbidden files were found: `h1-hteam05`, `h9`

To fix it, first make a backup of your repository and then run the following commands:
```bash
export GIT_BRANCH=$(git branch --show-current)
export GIT_REMOTE_URL=$(git config --get remote.origin.url)
for i in h1-hteam05 h9; do git filter-repo --force --invert-paths --path "$i"; done
git remote add origin $GIT_REMOTE_URL
git push --set-upstream origin $GIT_BRANCH --force

Non-ASCII Characters File Check Failed:

Non-ASCII characters found in the following files:
h2/README.md

should fix issue in https://focs.ji.sjtu.edu.cn/git/engr151-24fa/hteam-05 ```log ❯ ../JOJ3/build/healthcheck -root=. ### Forbidden File Check Failed: The following forbidden files were found: `h1-hteam05`, `h9` To fix it, first make a backup of your repository and then run the following commands: ```bash export GIT_BRANCH=$(git branch --show-current) export GIT_REMOTE_URL=$(git config --get remote.origin.url) for i in h1-hteam05 h9; do git filter-repo --force --invert-paths --path "$i"; done git remote add origin $GIT_REMOTE_URL git push --set-upstream origin $GIT_BRANCH --force ``` ### Non-ASCII Characters File Check Failed: Non-ASCII characters found in the following files: h2/README.md ```
周赵嘉程521432910016 added 1 commit 2024-10-17 16:13:30 +08:00
fix(healthcheck/forbidden): remove unused option
All checks were successful
build / build (pull_request) Successful in 1m5s
build / trigger-build-image (pull_request) Has been skipped
build / build (push) Successful in 1m6s
build / trigger-build-image (push) Has been skipped
f6012bdd5e
张泊明518370910136 reviewed 2024-10-17 16:48:50 +08:00
@ -18,2 +18,2 @@
var regexList []*regexp.Regexp
regexList, err := getRegex(fileList)
// Create a gitignore instance from the .gitignore file
ignore, err := gitignore.NewFromFile(filepath.Join(root, ".gitignore"))
  1. Check the existence of the root .gitignore file
  2. The .gitignore file may appear in sub-dirs, you also need to check them
1. Check the existence of the root `.gitignore` file 2. The `.gitignore` file may appear in sub-dirs, you also need to check them
Author
Member

So what's the default pattern if no gitignore? Warn student add a gitignore or set root as default value?

So what's the default pattern if no gitignore? Warn student add a gitignore or set root as default value?

what if the gitignore is nonsense? Not every course provide unchangeable gitignore

what if the gitignore is nonsense? Not every course provide unchangeable gitignore
Author
Member

Change to locallist and make it work as a gitignore file?

what if the gitignore is nonsense? Not every course provide unchangeable gitignore

Change to locallist and make it work as a gitignore file? > what if the gitignore is nonsense? Not every course provide unchangeable gitignore
Owner

with JOJ3 they must have an immutable gitignore or the server will quickly become a massive mess... caught a student who wanted to see what happened if he pushd a movie... repo was 2.8GB :/

with JOJ3 they **must** have an immutable gitignore or the server will quickly become a massive mess... caught a student who wanted to see what happened if he pushd a movie... repo was 2.8GB :/

If the forbidden check is enabled, then just throw error for no root gitignore or wrong root gitignore.

If the forbidden check is enabled, then just throw error for no root gitignore or wrong root gitignore.
bomingzh marked this conversation as resolved
张泊明518370910136 changed title from WIP: fix/forbidden to WIP: fix/forbidden (#58) 2024-10-17 16:50:59 +08:00

Also, add an option to healthcheck parser for stdout and stderr as we need to put them to /tmp/stdout and /tmp/stderr.

Also, add an option to healthcheck parser for stdout and stderr as we need to put them to `/tmp/stdout` and `/tmp/stderr`.
Author
Member

Also, add an option to healthcheck parser for stdout and stderr as we need to put them to /tmp/stdout and /tmp/stderr.

not sure what did you mean, can you explain more detailedly?

> Also, add an option to healthcheck parser for stdout and stderr as we need to put them to `/tmp/stdout` and `/tmp/stderr`. not sure what did you mean, can you explain more detailedly?
Author
Member

ignore the /w/tmp/?

ignore the /w/tmp/?

Now the hc parser is hardcoded to read stdout from file ./stdout and stderr from file ./stderr. But with this check, they can not be hardcoded, make them a config option.

Now the hc parser is hardcoded to read stdout from file `./stdout` and stderr from file `./stderr`. But with this check, they can not be hardcoded, make them a config option.

stdout := executorResult.Files["stdout"] => stdout := executorResult.Files[conf.Stdout]

`stdout := executorResult.Files["stdout"]` => `stdout := executorResult.Files[conf.Stdout]`
Author
Member

may need some time for this feature. A little busy recently.

The .gitignore file may appear in sub-dirs, you also need to check them

may need some time for this feature. A little busy recently. > The .gitignore file may appear in sub-dirs, you also need to check them
Author
Member

may be done this weekend

may be done this weekend
周赵嘉程521432910016 added 1 commit 2024-10-17 18:20:20 +08:00
feat(healthcheck/forbidden): gitignore in subdir
All checks were successful
build / build (push) Successful in 1m8s
build / trigger-build-image (push) Has been skipped
build / build (pull_request) Successful in 1m9s
build / trigger-build-image (pull_request) Has been skipped
44e3feb5c6
Author
Member

seems easier than i think @bomingzh plz check it. i don't sure is this function correctly implemented in package.

seems easier than i think @bomingzh plz check it. i don't sure is this function correctly implemented in package.

new test cases needed

new test cases needed
Author
Member

add a simple case here but I'm afraid that it is too simple. https://focs.ji.sjtu.edu.cn/git/JOJ/JOJ3-examples/src/branch/healthcheck/forbiddenfile

can anyone think about some more tricky cases.

add a simple case here but I'm afraid that it is too simple. https://focs.ji.sjtu.edu.cn/git/JOJ/JOJ3-examples/src/branch/healthcheck/forbiddenfile can anyone think about some more tricky cases.
Owner

can anyone think about some more tricky cases.

  • try a forbidden dir which has an allowed file inside
  • try a .DB_Store in a subdir

in 100 we need students to list their "allowed files" in a file (not strict pattern can be defined). so they use a file (messenger.json, which should be configured in repo level toml) to list their "self-allowed" files.

> can anyone think about some more tricky cases. - try a forbidden dir which has an allowed file inside - try a `.DB_Store` in a subdir in 100 we need students to list their "allowed files" in a file (not strict pattern can be defined). so they use a file (`messenger.json`, which should be configured in repo level toml) to list their "self-allowed" files.
Author
Member

@manuel like this?

output of hc


❯ ../JOJ3/build/healthcheck -root=.

Forbidden File Check Failed:

The following forbidden files were found: conf.json, expected.json, test/.DS_Store, test1, test1/test.md

To fix it, first make a backup of your repository and then run the following commands:

export GIT_BRANCH=$(git branch --show-current)
export GIT_REMOTE_URL=$(git config --get remote.origin.url)
for i in conf.json expected.json test/.DS_Store test1 test1/test.md; do git filter-repo --force --invert-paths --path "$i"; done
git remote add origin $GIT_REMOTE_URL
git push --set-upstream origin $GIT_BRANCH --force

.gitignore in root

**/*
test1/
!/test/
!stderr
!stdout
!*.md
!healthcheck
!.git*

test1/.gitignore

!*.json

file tree

❯ gtree . -a
.
├── .gitignore
├── README.md
├── conf.json
├── expected.json
├── test
│   ├── .DS_Store
│   ├── .gitignore
│   └── demo.json
└── test1
    └── test.md
@manuel like this? output of `hc` --- ❯ ../JOJ3/build/healthcheck -root=. ### Forbidden File Check Failed: The following forbidden files were found: `conf.json`, `expected.json`, `test/.DS_Store`, `test1`, `test1/test.md` To fix it, first make a backup of your repository and then run the following commands: ```bash export GIT_BRANCH=$(git branch --show-current) export GIT_REMOTE_URL=$(git config --get remote.origin.url) for i in conf.json expected.json test/.DS_Store test1 test1/test.md; do git filter-repo --force --invert-paths --path "$i"; done git remote add origin $GIT_REMOTE_URL git push --set-upstream origin $GIT_BRANCH --force ``` --- .gitignore in root ```gitignore **/* test1/ !/test/ !stderr !stdout !*.md !healthcheck !.git* ``` test1/.gitignore ```gitignore !*.json ``` file tree ```txt ❯ gtree . -a . ├── .gitignore ├── README.md ├── conf.json ├── expected.json ├── test │   ├── .DS_Store │   ├── .gitignore │   └── demo.json └── test1 └── test.md ```
Owner

what if you add test1/test2/test.c?

do we need to have a gitignore in each in each folder?

what if you add `test1/test2/test.c`? do we need to have a gitignore in each in each folder?
张泊明518370910136 requested changes 2024-10-18 11:04:13 +08:00
Dismissed
张泊明518370910136 left a comment
Owner

fix tests

fix tests
Author
Member

what do you mean? not sure about it

what if you add test1/test2/test.c?

do we need to have a gitignore in each in each folder?

what do you mean? not sure about it > what if you add test1/test2/test.c? > > do we need to have a gitignore in each in each folder?
Author
Member

.c file should be ignored or included by which gitignore?

.c file should be ignored or included by which gitignore?
周赵嘉程521432910016 added 1 commit 2024-10-18 14:31:04 +08:00
Merge branch 'master' into fix/forbidden
All checks were successful
build / build (push) Successful in 1m14s
build / build (pull_request) Successful in 1m13s
build / trigger-build-image (push) Has been skipped
build / trigger-build-image (pull_request) Has been skipped
240cc571bd
Author
Member

create a new pr for it?

Now the hc parser is hardcoded to read stdout from file ./stdout and stderr from file ./stderr. But with this check, they can not be hardcoded, make them a config option.

create a new pr for it? > Now the hc parser is hardcoded to read stdout from file ./stdout and stderr from file ./stderr. But with this check, they can not be hardcoded, make them a config option.
周赵嘉程521432910016 requested review from 张泊明518370910136 2024-10-18 14:33:13 +08:00
张泊明518370910136 changed title from WIP: fix/forbidden (#58) to fix/forbidden (#58) 2024-10-18 14:36:01 +08:00
张泊明518370910136 approved these changes 2024-10-18 14:39:50 +08:00
张泊明518370910136 merged commit b75a756998 into master 2024-10-18 14:41:10 +08:00
张泊明518370910136 deleted branch fix/forbidden 2024-10-18 14:41:10 +08:00

yes, new pr

yes, new pr
Owner

what if you add test1/test2/test.c?

suppose you have .gitignore at repo root, test1 dir is allowed and can contain *.c. what is happening if you create test1/test2/test.c?

do we need to have a gitignore in each in each folder?

in your example you have a .gitgnore containing !*.json (in test or test1 if i recall well). were you testing what is happening for a .gitignore in a subdir or this is because we should now have 1 gitignore per dir?

> what if you add test1/test2/test.c? suppose you have `.gitignore` at repo root, `test1` dir is allowed and can contain `*.c`. what is happening if you create `test1/test2/test.c`? > do we need to have a gitignore in each in each folder? in your example you have a `.gitgnore` containing `!*.json` (in test or test1 if i recall well). were you testing what is happening for a `.gitignore` in a subdir or this is because we should now have 1 `gitignore` per dir?
Author
Member

so you want to test whether the subdir of a subdir containing .gitignore follow the rule in the subdir?

so you want to test whether the subdir of a subdir containing .gitignore follow the rule in the subdir?
Sign in to join this conversation.
No description provided.