summaryrefslogtreecommitdiffstats
path: root/modules/util/util_test.go
Commit message (Collapse)AuthorAgeFilesLines
* Update go tool dependencies (#19676)silverwind2022-05-101-0/+5
| | | | | | | | | | | * Update go tool dependencies Updated all tool dependencies to latest tags, hoping CI will like it. * fix new lint errors * handle more strings.Title cases * remove lint skip
* Fix non-ASCII search on database (#18437)Gusted2022-02-011-0/+34
| | | Use `ToASCIIUpper` for SQLite database on issues search, this because `UPPER(x)` on SQLite only transforms ASCII letters. Resolves #18429
* Use base32 for 2FA scratch token (#18384)wxiaoguang2022-01-261-9/+9
| | | | * Use base32 for 2FA scratch token * rename Secure* to Crypto*, add comments
* format with gofumpt (#18184)65432022-01-201-1/+0
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Increase Salt randomness (#18179)Gusted2022-01-041-0/+18
| | | | | | | | | | | - The current implementation of `RandomString` doesn't give you a most-possible unique randomness. It gives you 6*`length` instead of the possible 8*`length` bits(or as `length`x bytes) randomness. This is because `RandomString` is being limited to a max value of 63, this in order to represent the random byte as a letter/digit. - The recommendation of pbkdf2 is to use 64+ bit salt, which the `RandomString` doesn't give with a length of 10, instead of increasing 10 to a higher number, this patch adds a new function called `RandomBytes` which does give you the guarentee of 8*`length` randomness and thus corresponding of `length`x bytes randomness. - Use hexadecimal to store the bytes value in the database, as mentioned, it doesn't play nice in order to convert it to a string. This will always be a length of 32(with `length` being 16). - When we detect on `Authenticate`(source: db) that a user has the old format of salt, re-hash the password such that the user will have it's password hashed with increased salt. Thanks to @zeripath for working out the rouge edges from my first commit 😄. Co-authored-by: lafriks <lauris@nix.lv> Co-authored-by: zeripath <art27@cantab.net>
* Add user status filter to admin user management page (#16770)wxiaoguang2021-10-121-0/+13
| | | | | | | | | | | | | | | | | | | | It makes Admin's life easier to filter users by various status. * introduce window.config.PageData to pass template data to javascript module and small refactor move legacy window.ActivityTopAuthors to window.config.PageData.ActivityTopAuthors make HTML structure more IDE-friendly in footer.tmpl and head.tmpl remove incorrect <style class="list-search-style"></style> in head.tmpl use log.Error instead of log.Critical in admin user search * use LEFT JOIN instead of SubQuery when admin filters users by 2fa. revert non-en locale. * use OptionalBool instead of status map * refactor SearchUserOptions.toConds to SearchUserOptions.toSearchQueryBase * add unit test for user search * only allow admin to use filters to search users
* Use single shared random string generation function (#15741)silverwind2021-05-101-0/+38
| | | | | | | | | | | | | | | | | | * Use single shared random string generation function - Replace 3 functions that do the same with 1 shared one - Use crypto/rand over math/rand for a stronger RNG - Output only alphanumerical for URL compatibilty Fixes: #15536 * use const string method * Update modules/avatar/avatar.go Co-authored-by: a1012112796 <1012112796@qq.com> Co-authored-by: a1012112796 <1012112796@qq.com>
* Re-attempt to delete temporary upload if the file is locked by another ↵zeripath2020-08-111-35/+0
| | | | | | | | | | | process (#12447) Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util. Fix #12339 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io>
* Convert EOL to UNIX-style to render MD properly (#8925)guillep2k2019-11-131-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Convert EOL to UNIX-style to render MD properly * Update modules/markup/markdown/markdown.go Co-Authored-By: zeripath <art27@cantab.net> * Fix lint optimization * Check for empty content before conversion * Update modules/util/util.go Co-Authored-By: zeripath <art27@cantab.net> * Improved checks and tests * Add paragraph render test * Improve speed even more, improve tests * Small improvement by @gary-kim * Fix test for DOS * More improvements * Restart CI
* Handle insecure and ports in go get (#7041)zeripath2019-05-271-1/+1
| | | | | | * Handle insecure and ports in go get * Fix IsExternalURL for non-standard ports
* Disallow empty titles (#5785)Lanre Adelowo2019-01-211-0/+17
| | | | | | | | | | | | * add util method and tests * make sure the title of an issue cannot be empty * wiki title cannot be empty * pull request title cannot be empty * update to make use of the new util methof
* Fix open redirect vulnerability on login screen (#4312)Jonas Franz2018-06-261-0/+35
| | | | | | | | | | | | | | * Fix open redirect vulnerability on login screen Signed-off-by: Jonas Franz <info@jonasfranz.software> * Reorder imports Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace www. from Domain too Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Fix #4081 Check for leading / in base before removing it (#4082)Antoine GIRARD2018-05-301-0/+6
|
* Fix relative markdown links with anchors (#4058)Jonas Franz2018-05-281-0/+2
| | | | | | | | | | | * Replace '%28' with '#' Add test case Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use ResolveReference instead of strings.Replace Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Populate URL field of API commits (#3546)Ethan Koenig2018-02-201-0/+36
* Populate URL field of API commits * fix orgmode_test