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
7e65bc46
Commit
7e65bc46
authored
3 years ago
by
Sven G. Brönstrup
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' into extended-scripts
parents
8f5af049
5060f68b
No related branches found
No related tags found
1 merge request
!1
Extended scripts support
Pipeline
#10240
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/Paths.hs
+8
-2
8 additions, 2 deletions
lib/Paths.hs
lib/Properties.hs
+2
-0
2 additions, 0 deletions
lib/Properties.hs
lib/Uris.hs
+5
-1
5 additions, 1 deletion
lib/Uris.hs
with
15 additions
and
3 deletions
lib/Paths.hs
+
8
−
2
View file @
7e65bc46
...
@@ -20,12 +20,18 @@ data RelPath = Path Int Text (Maybe Text)
...
@@ -20,12 +20,18 @@ data RelPath = Path Int Text (Maybe Text)
data
PathResult
=
OkRelPath
RelPath
|
AbsolutePath
|
NotAPath
|
UnderscoreMapLink
|
AtMapLink
data
PathResult
=
OkRelPath
RelPath
|
AbsolutePath
|
NotAPath
|
UnderscoreMapLink
|
AtMapLink
|
PathVarsDisallowed
-- | horrible regex parsing for filepaths that is hopefully kinda safe
-- | horrible regex parsing for filepaths that is hopefully kinda safe
parsePath
::
Text
->
PathResult
parsePath
::
Text
->
PathResult
parsePath
text
=
parsePath
text
=
if
|
rest
=~
(
"^([^/]*[^
\\
./]/)*[^/]*[^
\\
./]$"
::
Text
)
->
OkRelPath
(
Path
up
path
fragment
)
if
|
text
=~
(
"{{{.*}}}"
::
Text
)
->
PathVarsDisallowed
|
rest
=~
(
"^([^/]*[^
\\
./]/)*[^/]*[^
\\
./]$"
::
Text
)
->
OkRelPath
(
Path
up
path
fragment
)
|
"/_/"
`
isPrefixOf
`
text
->
UnderscoreMapLink
|
"/_/"
`
isPrefixOf
`
text
->
UnderscoreMapLink
|
"/@/"
`
isPrefixOf
`
text
->
AtMapLink
|
"/@/"
`
isPrefixOf
`
text
->
AtMapLink
|
"/"
`
isPrefixOf
`
text
->
AbsolutePath
|
"/"
`
isPrefixOf
`
text
->
AbsolutePath
...
...
This diff is collapsed.
Click to expand it.
lib/Properties.hs
+
2
−
0
View file @
7e65bc46
...
@@ -673,6 +673,7 @@ unwrapPath str f = case parsePath str of
...
@@ -673,6 +673,7 @@ unwrapPath str f = case parsePath str of
AbsolutePath
->
forbid
"absolute paths are disallowed. Use world:// instead."
AbsolutePath
->
forbid
"absolute paths are disallowed. Use world:// instead."
UnderscoreMapLink
->
forbid
"map links using /_/ are disallowed. Use world:// instead."
UnderscoreMapLink
->
forbid
"map links using /_/ are disallowed. Use world:// instead."
AtMapLink
->
forbid
"map links using /@/ are disallowed. Use world:// instead."
AtMapLink
->
forbid
"map links using /@/ are disallowed. Use world:// instead."
PathVarsDisallowed
->
forbid
"extended API variables are not allowed in asset paths."
unwrapBadgeToken
::
Text
->
(
BadgeToken
->
LintWriter
a
)
->
LintWriter
a
unwrapBadgeToken
::
Text
->
(
BadgeToken
->
LintWriter
a
)
->
LintWriter
a
unwrapBadgeToken
str
f
=
case
parseToken
str
of
unwrapBadgeToken
str
f
=
case
parseToken
str
of
...
@@ -700,6 +701,7 @@ unwrapURI sym p@(Property name _) f g = unwrapString p $ \link -> do
...
@@ -700,6 +701,7 @@ unwrapURI sym p@(Property name _) f g = unwrapString p $ \link -> do
\\"
"
<>
name
<>
"
\"
; allowed "
\\"
"
<>
name
<>
"
\"
; allowed "
<>
(
if
length
allowed
==
1
then
"is "
else
"are "
)
<>
(
if
length
allowed
==
1
then
"is "
else
"are "
)
<>
intercalate
", "
(
fmap
(
<>
"://"
)
allowed
)
<>
"."
<>
intercalate
", "
(
fmap
(
<>
"://"
)
allowed
)
<>
"."
VarsDisallowed
->
"extended API links are disallowed in links"
-- | just asserts that this is a string
-- | just asserts that this is a string
isString
::
Property
->
LintWriter
a
isString
::
Property
->
LintWriter
a
...
...
This diff is collapsed.
Click to expand it.
lib/Uris.hs
+
5
−
1
View file @
7e65bc46
...
@@ -9,7 +9,7 @@ module Uris where
...
@@ -9,7 +9,7 @@ module Uris where
import
Control.Monad
(
unless
)
import
Control.Monad
(
unless
,
when
)
import
Data.Aeson
(
FromJSON
(
..
),
Options
(
..
),
import
Data.Aeson
(
FromJSON
(
..
),
Options
(
..
),
SumEncoding
(
UntaggedValue
),
SumEncoding
(
UntaggedValue
),
defaultOptions
,
genericParseJSON
)
defaultOptions
,
genericParseJSON
)
...
@@ -58,6 +58,7 @@ data SubstError =
...
@@ -58,6 +58,7 @@ data SubstError =
|
IsBlocked
|
IsBlocked
|
DomainDoesNotExist
Text
|
DomainDoesNotExist
Text
|
WrongScope
Text
[
Text
]
|
WrongScope
Text
[
Text
]
|
VarsDisallowed
-- ^ This link's schema exists, but cannot be used in this scope.
-- ^ This link's schema exists, but cannot be used in this scope.
-- The second field contains a list of schemas that may be used instead.
-- The second field contains a list of schemas that may be used instead.
...
@@ -65,7 +66,10 @@ data SubstError =
...
@@ -65,7 +66,10 @@ data SubstError =
applySubst
::
KnownSymbol
s
applySubst
::
KnownSymbol
s
=>
Proxy
s
->
SchemaSet
->
Text
->
Either
SubstError
Text
=>
Proxy
s
->
SchemaSet
->
Text
->
Either
SubstError
Text
applySubst
s
substs
uri
=
do
applySubst
s
substs
uri
=
do
when
(
uri
=~
"{{{.*}}}"
)
$
Left
VarsDisallowed
(
schema
,
domain
,
rest
)
<-
note
NotALink
$
parseUri
uri
(
schema
,
domain
,
rest
)
<-
note
NotALink
$
parseUri
uri
rules
<-
note
(
SchemaDoesNotExist
schema
)
(
M
.
lookup
schema
substs
)
rules
<-
note
(
SchemaDoesNotExist
schema
)
(
M
.
lookup
schema
substs
)
unless
(
symbolVal
s
`
elem
`
scope
rules
)
unless
(
symbolVal
s
`
elem
`
scope
rules
)
$
Left
(
WrongScope
schema
$
Left
(
WrongScope
schema
...
...
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