aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-01-05 19:48:47 +0100
committerzeripath <art27@cantab.net>2020-01-05 18:48:47 +0000
commit133ae18b61c5d3bdfc7670b8320abe84dd96cbe2 (patch)
treef0578979a35ff329499b83888aa6f9e5278cb9c3 /models
parent7e4f490482014fa52d15902b5aa20952461c64f4 (diff)
downloadgitea-133ae18b61c5d3bdfc7670b8320abe84dd96cbe2.tar.gz
gitea-133ae18b61c5d3bdfc7670b8320abe84dd96cbe2.zip
[BugFix] Hide public repos owned by private orgs (#9609)
* Restrict AllPublic to actually public repos. * Add new parameter to add in AllLimited Repos
Diffstat (limited to 'models')
-rw-r--r--models/repo_list.go9
-rw-r--r--models/repo_list_test.go4
2 files changed, 9 insertions, 4 deletions
diff --git a/models/repo_list.go b/models/repo_list.go
index 34fac8b055..7b48834dba 100644
--- a/models/repo_list.go
+++ b/models/repo_list.go
@@ -121,7 +121,8 @@ type SearchRepoOptions struct {
StarredByID int64
Page int
IsProfile bool
- AllPublic bool // Include also all public repositories
+ AllPublic bool // Include also all public repositories of users and public organisations
+ AllLimited bool // Include also all public repositories of limited organisations
PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
// None -> include collaborative AND non-collaborative
// True -> include just collaborative
@@ -228,7 +229,11 @@ func SearchRepository(opts *SearchRepoOptions) (RepositoryList, int64, error) {
}
if opts.AllPublic {
- accessCond = accessCond.Or(builder.Eq{"is_private": false})
+ accessCond = accessCond.Or(builder.Eq{"is_private": false}.And(builder.In("owner_id", builder.Select("`user`.id").From("`user`").Where(builder.Eq{"`user`.visibility": structs.VisibleTypePublic}))))
+ }
+
+ if opts.AllLimited {
+ accessCond = accessCond.Or(builder.Eq{"is_private": false}.And(builder.In("owner_id", builder.Select("`user`.id").From("`user`").Where(builder.Eq{"`user`.visibility": structs.VisibleTypeLimited}))))
}
cond = cond.And(accessCond)
diff --git a/models/repo_list_test.go b/models/repo_list_test.go
index a1eed18b83..07f84207e2 100644
--- a/models/repo_list_test.go
+++ b/models/repo_list_test.go
@@ -177,8 +177,8 @@ func TestSearchRepository(t *testing.T) {
opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, AllPublic: true, Template: util.OptionalBoolFalse},
count: 25},
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborative",
- opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true, Template: util.OptionalBoolFalse},
- count: 31},
+ opts: &SearchRepoOptions{Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true, AllLimited: true, Template: util.OptionalBoolFalse},
+ count: 30},
{name: "AllPublic/PublicAndPrivateRepositoriesOfUserIncludingCollaborativeByName",
opts: &SearchRepoOptions{Keyword: "test", Page: 1, PageSize: 10, OwnerID: 15, Private: true, AllPublic: true},
count: 15},
e='backport/44295/stable29'>backport/44295/stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/composer.json
blob: dcbd908c0262812c677d57981c17fa2856207789 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
	"config": {
		"vendor-dir": "lib/composer",
		"optimize-autoloader": true,
		"sort-packages": true,
		"platform": {
			"php": "8.0"
		},
		"allow-plugins": {
			"bamarni/composer-bin-plugin": true
		}
	},
	"autoload": {
		"files": [
			"lib/public/Log/functions.php"
		],
		"psr-4": {
			"": "lib/private/legacy",
			"OC\\": "lib/private",
			"OC\\Core\\": "core/",
			"OCP\\": "lib/public"
		}
	},
	"require": {
		"php": "^8.0",
		"ext-ctype": "*",
		"ext-curl": "*",
		"ext-dom": "*",
		"ext-fileinfo": "*",
		"ext-gd": "*",
		"ext-json": "*",
		"ext-libxml": "*",
		"ext-mbstring": "*",
		"ext-openssl": "*",
		"ext-pdo": "*",
		"ext-posix": "*",
		"ext-session": "*",
		"ext-simplexml": "*",
		"ext-xml": "*",
		"ext-xmlreader": "*",
		"ext-xmlwriter": "*",
		"ext-zip": "*",
		"ext-zlib": "*"
	},
	"require-dev": {
		"bamarni/composer-bin-plugin": "^1.4"
	},
	"scripts": {
		"post-install-cmd": [
			"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all install",
			"composer dump-autoload"
		],
		"post-update-cmd": [
			"[ $COMPOSER_DEV_MODE -eq 0 ] || composer bin all update --ansi",
			"composer dump-autoload"
		],
		"cs:fix": "php-cs-fixer fix",
		"cs:check": "php-cs-fixer fix --dry-run --diff",
		"lint": "find . -name \\*.php -not -path './lib/composer/*' -not -path './build/stubs/*' -print0 | xargs -0 -n1 php -l",
		"psalm": "psalm --no-cache --threads=$(nproc)",
		"psalm:ci": "psalm --no-cache --threads=1",
		"psalm:update-baseline": "psalm --no-cache --threads=$(nproc) --update-baseline",
		"serve": [
			"Composer\\Config::disableProcessTimeout",
			"PHP_CLI_SERVER_WORKERS=${NEXTCLOUD_WORKERS:=4} php -S ${NEXTCLOUD_HOST:=localhost}:${NEXTCLOUD_PORT:=8080} -t ./"
		],
		"test": "phpunit --configuration tests/phpunit-autotest.xml",
		"test:db": "@composer run test -- --group DB,SLOWDB",
		"test:files_external": "phpunit --configuration tests/phpunit-autotest-external.xml"
	}
}