Skip to content

Commit a943f0d

Browse files
committed
refactoring: extract core and osv
1 parent 6c9ec32 commit a943f0d

File tree

25 files changed

+427
-33
lines changed

25 files changed

+427
-33
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ jobs:
181181
- name: initial cabal.project for sdist
182182
run: |
183183
touch cabal.project
184+
echo "packages: $GITHUB_WORKSPACE/source/code/hsec-core" >> cabal.project
184185
echo "packages: $GITHUB_WORKSPACE/source/code/hsec-tools" >> cabal.project
185186
echo "packages: $GITHUB_WORKSPACE/source/code/cvss" >> cabal.project
187+
echo "packages: $GITHUB_WORKSPACE/source/code/osv" >> cabal.project
186188
cat cabal.project
187189
- name: sdist
188190
run: |
@@ -196,20 +198,34 @@ jobs:
196198
run: |
197199
PKGDIR_hsec_tools="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hsec-tools-[0-9.]*')"
198200
echo "PKGDIR_hsec_tools=${PKGDIR_hsec_tools}" >> "$GITHUB_ENV"
201+
PKGDIR_hsec_tools="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hsec-tools-[0-9.]*')"
202+
echo "PKGDIR_hsec_tools=${PKGDIR_hsec_tools}" >> "$GITHUB_ENV"
203+
PKGDIR_hsec_core="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hsec-core-[0-9.]*')"
204+
echo "PKGDIR_hsec_core=${PKGDIR_hsec_core}" >> "$GITHUB_ENV"
205+
PKGDIR_osv="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/osv-[0-9.]*')"
206+
echo "PKGDIR_osv=${PKGDIR_osv}" >> "$GITHUB_ENV"
199207
PKGDIR_cvss="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/cvss-[0-9.]*')"
200208
echo "PKGDIR_cvss=${PKGDIR_cvss}" >> "$GITHUB_ENV"
201209
rm -f cabal.project cabal.project.local
202210
touch cabal.project
203211
touch cabal.project.local
212+
echo "packages: ${PKGDIR_hsec_core}" >> cabal.project
204213
echo "packages: ${PKGDIR_hsec_tools}" >> cabal.project
214+
echo "packages: ${PKGDIR_osv}" >> cabal.project
205215
echo "packages: ${PKGDIR_cvss}" >> cabal.project
206216
echo "package hsec-tools" >> cabal.project
207217
echo " ghc-options: -Werror=missing-methods" >> cabal.project
218+
echo "package hsec-tools" >> cabal.project
219+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
220+
echo "package hsec-core" >> cabal.project
221+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
222+
echo "package osv" >> cabal.project
223+
echo " ghc-options: -Werror=missing-methods" >> cabal.project
208224
echo "package cvss" >> cabal.project
209225
echo " ghc-options: -Werror=missing-methods" >> cabal.project
210226
cat >> cabal.project <<EOF
211227
EOF
212-
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(cvss|hsec-tools)$/; }' >> cabal.project.local
228+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(cvss|osv|hsec-core|hsec-tools)$/; }' >> cabal.project.local
213229
cat cabal.project
214230
cat cabal.project.local
215231
- name: dump install plan
@@ -239,13 +255,19 @@ jobs:
239255
run: |
240256
if [ $((HCNUMVER >= 90400 && HCNUMVER < 90600)) -ne 0 ] ; then (cd ${PKGDIR_hsec_tools} && hlint -XHaskell2010 src) ; fi
241257
if [ $((HCNUMVER >= 90400 && HCNUMVER < 90600)) -ne 0 ] ; then (cd ${PKGDIR_hsec_tools} && hlint -XHaskell2010 app) ; fi
258+
if [ $((HCNUMVER >= 90400 && HCNUMVER < 90600)) -ne 0 ] ; then (cd ${PKGDIR_hsec_core} && hlint -XHaskell2010 src) ; fi
259+
if [ $((HCNUMVER >= 90400 && HCNUMVER < 90600)) -ne 0 ] ; then (cd ${PKGDIR_osv} && hlint -XHaskell2010 src) ; fi
242260
if [ $((HCNUMVER >= 90400 && HCNUMVER < 90600)) -ne 0 ] ; then (cd ${PKGDIR_cvss} && hlint -XHaskell2010 src) ; fi
243261
- name: cabal check
244262
run: |
263+
cd ${PKGDIR_hsec_core} || false
264+
${CABAL} -vnormal check
245265
cd ${PKGDIR_hsec_tools} || false
246266
${CABAL} -vnormal check
247267
cd ${PKGDIR_cvss} || false
248268
${CABAL} -vnormal check
269+
cd ${PKGDIR_osv} || false
270+
${CABAL} -vnormal check
249271
- name: haddock
250272
run: |
251273
$CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all

cabal.project

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
packages: code/*/*.cabal
22

3+
package hsec-core
34
package hsec-tools
45
package cvss
6+
package osv

code/hsec-core/.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
##### Haskell
2+
dist
3+
dist-*
4+
cabal-dev
5+
*.o
6+
*.hi
7+
*.hie
8+
*.chi
9+
*.chs.h
10+
*.dyn_o
11+
*.dyn_hi
12+
.hpc
13+
.hsenv
14+
.cabal-sandbox/
15+
cabal.sandbox.config
16+
*.prof
17+
*.aux
18+
*.hp
19+
*.eventlog
20+
.stack-work/
21+
cabal.project.local
22+
cabal.project.local~
23+
.HTF/
24+
.ghc.environment.*
25+
build
26+
bin-*
27+
28+
result
29+
.direnv
30+
.env

code/hsec-core/CHANGELOG.md

Whitespace-only changes.

code/hsec-core/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# hsec-core
2+
3+
`hesc-core` aims to support [Haskell advisories database](https://github.com/haskell/security-advisories).
4+
5+
## Building
6+
7+
We aim to support both regular cabal-based and nix-based builds.
8+
9+
## Testing
10+
11+
Run (and auto update) the golden test:
12+
13+
```ShellSession
14+
cabal test -O0 --test-show-details=direct --test-option=--accept
15+
```

code/hsec-core/hsec-core.cabal

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
cabal-version: 2.4
2+
name: hsec-core
3+
version: 0.1.0.0
4+
5+
-- A short (one-line) description of the package.
6+
synopsis: Core package representing Haskell advisories
7+
8+
-- A longer description of the package.
9+
description: Core package representing Haskell advisories.
10+
11+
-- A URL where users can report bugs.
12+
-- bug-reports:
13+
14+
-- The license under which the package is released.
15+
license: BSD-3-Clause
16+
author: David Christiansen
17+
maintainer: [email protected]
18+
19+
-- A copyright notice.
20+
-- copyright:
21+
category: Data
22+
extra-doc-files: CHANGELOG.md
23+
24+
tested-with:
25+
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3 || ==9.8.1
26+
27+
library
28+
exposed-modules:
29+
Security.Advisories.Core.Advisory
30+
Security.Advisories.Core.HsecId
31+
32+
build-depends:
33+
, base >=4.14 && <4.20
34+
, Cabal-syntax >=3.8.1.0 && <3.11
35+
, cvss
36+
, osv
37+
, pandoc-types >=1.22 && <2
38+
, safe >=0.3
39+
, text >=1.2 && <3
40+
, time >=1.9 && <1.14
41+
42+
-- , commonmark ^>=0.2.2
43+
-- , commonmark-pandoc >=0.2 && <0.3
44+
-- , containers >=0.6 && <0.7
45+
-- , mtl >=2.2 && <2.4
46+
hs-source-dirs: src
47+
default-language: Haskell2010
48+
ghc-options:
49+
-Wall -Wcompat -Widentities -Wincomplete-record-updates
50+
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints
51+
52+
test-suite spec
53+
type: exitcode-stdio-1.0
54+
hs-source-dirs: test
55+
main-is: Spec.hs
56+
build-depends:
57+
, base <5
58+
, cvss
59+
, hsec-core
60+
, tasty <1.5
61+
, tasty-hunit <0.11
62+
, text
63+
64+
default-language: Haskell2010
65+
ghc-options:
66+
-Wall -Wcompat -Widentities -Wincomplete-record-updates
67+
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints

code/hsec-tools/src/Security/Advisories/Definition.hs renamed to code/hsec-core/src/Security/Advisories/Core/Advisory.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE DerivingVia #-}
22

3-
module Security.Advisories.Definition
3+
module Security.Advisories.Core.Advisory
44
( Advisory(..)
55
-- * Supporting types
66
, Affected(..)
@@ -19,7 +19,7 @@ import Distribution.Types.VersionRange (VersionRange)
1919

2020
import Text.Pandoc.Definition (Pandoc)
2121

22-
import Security.Advisories.HsecId
22+
import Security.Advisories.Core.HsecId
2323
import qualified Security.CVSS as CVSS
2424
import Security.OSV (Reference)
2525

code/hsec-tools/src/Security/Advisories/HsecId.hs renamed to code/hsec-core/src/Security/Advisories/Core/HsecId.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Security.Advisories.HsecId
1+
module Security.Advisories.Core.HsecId
22
(
33
HsecId
44
, hsecIdYear

code/hsec-core/test/Spec.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module Main where
2+
3+
import Test.Tasty
4+
5+
main :: IO ()
6+
main =
7+
defaultMain $
8+
testGroup
9+
"Tests"
10+
[]

code/hsec-tools/app/Command/Reserve.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Security.Advisories.Git
1313
, explainGitError
1414
, getRepoRoot
1515
)
16-
import Security.Advisories.HsecId
16+
import Security.Advisories.Core.HsecId
1717
( placeholder
1818
, printHsecId
1919
, getNextHsecId

0 commit comments

Comments
 (0)