Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kawaii
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
Container Registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Trujillo
kawaii
Commits
71f89c1a
Commit
71f89c1a
authored
4 years ago
by
Eduardo Trujillo
Browse files
Options
Downloads
Patches
Plain Diff
Make CSP directives more Yaml/Json friendly
parent
7eb4928f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#32
failed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Network/Http/Csp.hs
+23
-6
23 additions, 6 deletions
src/Network/Http/Csp.hs
with
23 additions
and
6 deletions
src/Network/Http/Csp.hs
+
23
−
6
View file @
71f89c1a
...
...
@@ -2,6 +2,7 @@
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
-- |
--
...
...
@@ -40,15 +41,21 @@ type Parser = Parsec Void Text
data
SchemePart
=
SchemePart
Text
deriving
(
Show
,
Eq
,
Generic
)
data
PortPart
=
SpecificPort
Integer
|
AnyPort
deriving
(
Show
,
Eq
,
Generic
)
data
HostPart
=
AnyHostPart
|
DomainHostPart
Bool
Text
deriving
(
Show
,
Eq
,
Generic
)
data
HostPart
=
AnyHostPart
|
DomainHostPart
{
wildcard
::
Bool
,
domain
::
Text
}
deriving
(
Show
,
Eq
,
Generic
)
data
PathPart
=
PathPart
Text
deriving
(
Show
,
Eq
,
Generic
)
instance
ToCSP
SchemePart
where
toCSP
(
SchemePart
scheme
)
=
scheme
toCSP
(
SchemePart
scheme
_
)
=
scheme
_
instance
FromJSON
SchemePart
instance
ToCSP
PortPart
where
toCSP
(
SpecificPort
port
)
=
T
.
pack
.
show
$
port
toCSP
(
SpecificPort
port
_
)
=
T
.
pack
.
show
$
port
_
toCSP
AnyPort
=
"*"
instance
FromJSON
PortPart
...
...
@@ -60,7 +67,7 @@ instance ToCSP HostPart where
instance
FromJSON
HostPart
instance
ToCSP
PathPart
where
toCSP
(
PathPart
path
)
=
path
toCSP
(
PathPart
path
_
)
=
path
_
instance
FromJSON
PathPart
alphaChar
::
Parser
Char
...
...
@@ -198,7 +205,12 @@ pHashAlgorithm = choice
data
SourceExpression
=
SchemeSource
SchemePart
|
HostSource
(
Maybe
SchemePart
)
HostPart
(
Maybe
PortPart
)
(
Maybe
PathPart
)
|
HostSource
{
scheme
::
Maybe
SchemePart
,
host
::
HostPart
,
port
::
Maybe
PortPart
,
path
::
Maybe
PathPart
}
|
KeywordSource
Keyword
|
NonceSource
Text
|
HashSource
HashAlgorithm
Text
...
...
@@ -247,7 +259,12 @@ pSourceExpression = choice
data
AncestorSource
=
AncestorSchemeSource
SchemePart
|
AncestorHostSource
(
Maybe
SchemePart
)
HostPart
(
Maybe
PortPart
)
(
Maybe
PathPart
)
|
AncestorHostSource
{
scheme
::
Maybe
SchemePart
,
host
::
HostPart
,
port
::
Maybe
PortPart
,
path
::
Maybe
PathPart
}
|
AncestorSelfSource
deriving
(
Show
,
Eq
,
Generic
)
...
...
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