Skip to content

Commit

Permalink
[chore] init hsec-cabal project
Browse files Browse the repository at this point in the history
- move to more declarative flake setup to avoid complexity
- init the hsec-cabal cabal project
- move the cabal.project file to `code`
  • Loading branch information
MangoIV committed Feb 6, 2024
1 parent bd41966 commit 3e093fe
Show file tree
Hide file tree
Showing 19 changed files with 413 additions and 168 deletions.
5 changes: 0 additions & 5 deletions .envrc

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*~
dist-newstyle/
result
result*
.direnv
.env
.pre-commit-config.yaml
6 changes: 0 additions & 6 deletions cabal.project

This file was deleted.

1 change: 1 addition & 0 deletions code/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake .. -Lv
6 changes: 6 additions & 0 deletions code/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages:
./hsec-core
./hsec-tools
./hsec-cabal
./cvss
./osv
3 changes: 2 additions & 1 deletion code/cvss/cvss.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ author: Tristan de Cacqueray
maintainer: tdecacqu@redhat.com
category: Data
extra-doc-files: CHANGELOG.md
tested-with: GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3 || ==9.8.1
tested-with:
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3 || ==9.8.1

library
exposed-modules: Security.CVSS
Expand Down
6 changes: 6 additions & 0 deletions code/hsec-cabal/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main (main) where

import Distribution.Audit (auditMain)

main :: IO ()
main = auditMain
12 changes: 12 additions & 0 deletions code/hsec-cabal/fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
indentation: 2
function-arrows: leading
comma-style: leading
import-export-style: leading
indent-wheres: false
record-brace-space: true
newlines-between-decls: 1
haddock-style: single-line
let-style: inline
in-style: right-align
respectful: false
single-constraint-parens: never
73 changes: 73 additions & 0 deletions code/hsec-cabal/hsec-cabal.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
cabal-version: 2.4
name: hsec-cabal
version: 0.1.0.0

-- A short (one-line) description of the package.
synopsis: Checking a cabal project for security advisories

-- A longer description of the package.
description:
Tools for querying the haskell security advisories database against cabal projects.

-- A URL where users can report bugs.
-- bug-reports:

-- The license under which the package is released.
license: BSD-3-Clause
author: @MangoIV
maintainer: contact@mangoiv.com

-- A copyright notice.
-- copyright:
category: Data
extra-doc-files: CHANGELOG.md
extra-source-files:
tested-with:
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3 || ==9.8.1

common common-all
ghc-options:
-Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints

default-extensions:
BlockArguments
DeriveGeneric
DerivingStrategies

library
import: common-all
exposed-modules:
Distribution.Audit
Distribution.Audit.Option
Security.Advisories.Cabal

build-depends:
, base <5
, cabal-install
, Cabal-syntax
, hsec-core
, optparse-applicative

hs-source-dirs: src
default-language: Haskell2010

executable cabal-audit
import: common-all
hs-source-dirs: app
main-is: Main.hs
other-modules:
build-depends:
, base <5
, hsec-cabal

default-language: Haskell2010

test-suite spec
import: common-all
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
other-modules:
build-depends: base <5
default-language: Haskell2010
5 changes: 5 additions & 0 deletions code/hsec-cabal/src/Distribution/Audit.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Distribution.Audit (auditMain) where

auditMain :: IO ()
auditMain = do
putStrLn "unimplemented"
18 changes: 18 additions & 0 deletions code/hsec-cabal/src/Distribution/Audit/Option.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- TODO(mangoiv): implement a proper parser as well as proper options to
-- - use constraints from a cabal file
-- - use a cabal.freeze file
-- - solve and then use cabal.freeze obtained
module Distribution.Audit.Option
( CabalAuditOptions (..)
, cabalAuditParser
)
where

import GHC.Generics (Generic)
import Options.Applicative (Parser)

data CabalAuditOptions = MkCabalAuditOptions {}
deriving stock (Eq, Ord, Show, Generic)

cabalAuditParser :: Parser CabalAuditOptions
cabalAuditParser = pure MkCabalAuditOptions
1 change: 1 addition & 0 deletions code/hsec-cabal/src/Security/Advisories/Cabal.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Security.Advisories.Cabal where
4 changes: 4 additions & 0 deletions code/hsec-cabal/test/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Main where

main :: IO ()
main = pure ()
4 changes: 4 additions & 0 deletions code/hsec-cabal/test/assets/test-a/src/MyLib.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MyLib (someFunc) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"
25 changes: 25 additions & 0 deletions code/hsec-cabal/test/assets/test-a/test-a.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cabal-version: 3.0
name: test-a
version: 0.1.0.0
license: MIT
license-file: LICENSE
author: mangoiv
maintainer: mail@mangoiv.com
category: Codec
build-type: Simple
extra-doc-files: CHANGELOG.md

common warnings
ghc-options: -Wall

library
import: warnings
exposed-modules: MyLib

-- hakyll depends on pandoc which has a security report
build-depends:
, base
, hakyll

hs-source-dirs: src
default-language: Haskell2010
21 changes: 10 additions & 11 deletions code/hsec-core/hsec-core.cabal
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
cabal-version: 2.4
name: hsec-core
version: 0.1.0.0
cabal-version: 2.4
name: hsec-core
version: 0.1.0.0

-- A short (one-line) description of the package.
synopsis: Core package representing Haskell advisories
synopsis: Core package representing Haskell advisories

-- A longer description of the package.
description: Core package representing Haskell advisories.
description: Core package representing Haskell advisories.

-- A URL where users can report bugs.
-- bug-reports:

-- The license under which the package is released.
license: BSD-3-Clause
author: David Christiansen
maintainer: david@davidchristiansen.dk
license: BSD-3-Clause
author: David Christiansen
maintainer: david@davidchristiansen.dk

-- A copyright notice.
-- copyright:
category: Data
extra-doc-files: CHANGELOG.md

category: Data
extra-doc-files: CHANGELOG.md
tested-with:
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3 || ==9.8.1

Expand Down
41 changes: 18 additions & 23 deletions code/osv/osv.cabal
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
cabal-version: 2.4
name: osv
version: 0.1.0.0
cabal-version: 2.4
name: osv
version: 0.1.0.0

-- A short (one-line) description of the package.
synopsis:
Open Source Vulnerability format
synopsis: Open Source Vulnerability format

-- A longer description of the package.
description:
Open Source Vulnerability format.
description: Open Source Vulnerability format.

-- A URL where users can report bugs.
-- bug-reports:

-- The license under which the package is released.
license: BSD-3-Clause
author: David Christiansen
maintainer: david@davidchristiansen.dk
license: BSD-3-Clause
author: David Christiansen
maintainer: david@davidchristiansen.dk

-- A copyright notice.
-- copyright:
category: Data
extra-doc-files: CHANGELOG.md

category: Data
extra-doc-files: CHANGELOG.md
tested-with:
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3 || ==9.8.1

library
exposed-modules:
Security.OSV

exposed-modules: Security.OSV
build-depends:
, aeson >=2.0.1.0 && <3
, base >=4.14 && <4.20
, aeson >=2.0.1.0 && <3
, base >=4.14 && <4.20
, cvss
, text >=1.2 && <3
, time >=1.9 && <1.14
, text >=1.2 && <3
, time >=1.9 && <1.14

hs-source-dirs: src
default-language: Haskell2010
Expand All @@ -48,10 +43,10 @@ test-suite spec
hs-source-dirs: test
main-is: Spec.hs
build-depends:
, base <5
, base <5
, osv
, tasty <1.5
, tasty-hunit <0.11
, tasty <1.5
, tasty-hunit <0.11

default-language: Haskell2010
ghc-options:
Expand Down

0 comments on commit 3e093fe

Please sign in to comment.