Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
hub
walint
Commits
25111b46
Commit
25111b46
authored
3 years ago
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
linter: allow unrestricted domain scopes
parent
8a0a463f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
config.json
+8
-15
8 additions, 15 deletions
config.json
lib/Uris.hs
+7
-8
7 additions, 8 deletions
lib/Uris.hs
with
15 additions
and
23 deletions
config.json
+
8
−
15
View file @
25111b46
...
@@ -3,23 +3,16 @@
...
@@ -3,23 +3,16 @@
"Assemblies"
:[],
"Assemblies"
:[],
"ScriptInject"
:
null
,
"ScriptInject"
:
null
,
"AllowScripts"
:
false
,
"AllowScripts"
:
false
,
"MaxLintLevel"
:
"
Warning
"
,
"MaxLintLevel"
:
"
Fatal
"
,
"DontCopyAssets"
:
false
,
"DontCopyAssets"
:
false
,
"UriSchemas"
:
[
"UriSchemas"
:
{
[
"https"
,
{
"world"
:
{
"scope"
:
[
"website"
],
"allowed"
:
[
"media.ccc.de"
,
"streaming.media.ccc.de"
,
"static.rc3.world"
,
"cdn.c3voc.de"
,
"pretalx.c3voc.de"
],
"blocked"
:
[
"blocked.com"
],
"prefix"
:
"https:
\/\/
rc3.world
\/
2021
\/
wa_dereferrer
\/
"
}],
[
"https"
,
{
"scope"
:
[
"audio"
],
"allowed"
:
[
"cdn.c3voc.de"
,
"media.ccc.de"
,
"streaming.media.ccc.de"
,
"static.rc3.world"
,
"live.dort.c3voc.de"
]
}],
[
"world"
,
{
"scope"
:
[
"map"
],
"scope"
:
[
"map"
],
"substs"
:
{
"substs"
:
{
}
}
}]
},
]
"https"
:
{
"scope"
:
[
"website"
,
"audio"
]
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/Uris.hs
+
7
−
8
View file @
25111b46
...
@@ -23,6 +23,7 @@ data Substitution =
...
@@ -23,6 +23,7 @@ data Substitution =
Prefixed
{
prefix
::
Text
,
blocked
::
[
Text
],
allowed
::
[
Text
],
scope
::
[
String
]
}
Prefixed
{
prefix
::
Text
,
blocked
::
[
Text
],
allowed
::
[
Text
],
scope
::
[
String
]
}
|
DomainSubstitution
{
substs
::
Map
Text
Text
,
scope
::
[
String
]
}
|
DomainSubstitution
{
substs
::
Map
Text
Text
,
scope
::
[
String
]
}
|
Allowed
{
scope
::
[
String
],
allowed
::
[
Text
]
}
|
Allowed
{
scope
::
[
String
],
allowed
::
[
Text
]
}
|
Unrestricted
{
scope
::
[
String
]
}
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
...
@@ -32,7 +33,7 @@ instance FromJSON Substitution where
...
@@ -32,7 +33,7 @@ instance FromJSON Substitution where
,
rejectUnknownFields
=
True
,
rejectUnknownFields
=
True
}
}
type
SchemaSet
=
[(
Text
,
Substitution
)]
type
SchemaSet
=
Map
Text
Substitution
extractDomain
::
Text
->
Maybe
Text
extractDomain
::
Text
->
Maybe
Text
...
@@ -78,20 +79,17 @@ applySubsts s substs uri = do
...
@@ -78,20 +79,17 @@ applySubsts s substs uri = do
$
Left
VarsDisallowed
$
Left
VarsDisallowed
parts
@
(
schema
,
_
,
_
)
<-
note
NotALink
$
parseUri
uri
parts
@
(
schema
,
_
,
_
)
<-
note
NotALink
$
parseUri
uri
let
rule
s
=
filter
((
==
)
schema
.
fst
)
substs
let
rule
=
M
.
lookup
schema
substs
case
nonEmpty
(
map
(
applySubst
parts
.
snd
)
rule
s
)
of
case
map
(
applySubst
parts
)
rule
of
Nothing
->
Left
(
SchemaDoesNotExist
schema
)
Nothing
->
Left
(
SchemaDoesNotExist
schema
)
Just
results
->
case
rights
(
toList
results
)
of
Just
result
->
result
suc
:
_
->
Right
suc
_
->
minimum
results
where
where
note
=
maybeToRight
note
=
maybeToRight
applySubst
(
schema
,
domain
,
rest
)
rule
=
do
applySubst
(
schema
,
domain
,
rest
)
rule
=
do
unless
(
symbolVal
s
`
elem
`
scope
rule
)
unless
(
symbolVal
s
`
elem
`
scope
rule
)
$
Left
(
WrongScope
schema
$
Left
(
WrongScope
schema
(
f
map
fst
.
filter
(
elem
(
symbolVal
s
)
.
scope
.
snd
)
$
substs
))
(
map
fst
.
filter
(
elem
(
symbolVal
s
)
.
scope
.
snd
)
$
toPairs
substs
))
case
rule
of
case
rule
of
DomainSubstitution
table
_
->
do
DomainSubstitution
table
_
->
do
prefix
<-
note
(
DomainDoesNotExist
(
schema
<>
toText
"://"
<>
domain
))
prefix
<-
note
(
DomainDoesNotExist
(
schema
<>
toText
"://"
<>
domain
))
...
@@ -105,3 +103,4 @@ applySubsts s substs uri = do
...
@@ -105,3 +103,4 @@ applySubsts s substs uri = do
||
toText
"streamproxy.rc3.world"
`
T
.
isSuffixOf
`
domain
||
toText
"streamproxy.rc3.world"
`
T
.
isSuffixOf
`
domain
then
Right
uri
then
Right
uri
else
Left
(
DomainIsBlocked
domains
)
else
Left
(
DomainIsBlocked
domains
)
Unrestricted
_
->
Right
uri
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment