Skip to content

Commit

Permalink
Implement recommendations from elm-analyse
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoppmann committed Oct 16, 2019
1 parent e4fb372 commit 193c3ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 11 additions & 1 deletion src/Cvss.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Cvss exposing (..)
module Cvss exposing (AttackComplexity(..), AttackVector(..), AvailabilityImpact(..), ConfidentialityImpact(..), IntegrityImpact(..), PrivilegesRequired(..), Scope(..), Severity(..), UserInteraction(..), Vector, calculateBaseScore, getMatchingVector, initVector, minPrecision, randomVector, toSeverityVector, toStringSeverity, toStringVector)

import Random
import Random.Extra exposing (andMap)
Expand All @@ -12,6 +12,7 @@ import Round exposing (ceilingNum)
{-| The minimal precision when a vector score is seen as valid.
The value is needed, because there are some ranges where there are no matching vectors.
-}
minPrecision : Float
minPrecision =
1.0

Expand Down Expand Up @@ -82,6 +83,11 @@ type Severity
| SNone


initVector : Vector
initVector =
Vector AvNetwork AcLow PrNone UiNone SUnchanged CNone INone ANone



-- CVSSV3 CALCULATION

Expand Down Expand Up @@ -485,6 +491,10 @@ randomAvailabilityImpact =
Random.uniform ANone [ ALow, AHigh ]



-- SEVERITY


toSeverityVector : Vector -> Severity
toSeverityVector vector =
let
Expand Down
13 changes: 5 additions & 8 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ module Main exposing (Model, Msg(..), init, main, update, view)
import Browser
import Browser.Dom exposing (Viewport, getViewport)
import Browser.Events exposing (onResize)
import Cvss exposing (..)
import Dict exposing (Dict)
import Cvss exposing (Severity(..), Vector, calculateBaseScore, getMatchingVector, initVector, minPrecision, randomVector, toSeverityVector, toStringSeverity, toStringVector)
import Element exposing (Color, Device, DeviceClass(..), Element, Orientation(..), alignRight, behindContent, centerX, centerY, classifyDevice, column, el, fill, height, layout, link, none, padding, px, rgb, rgb255, rgba, row, shrink, spacing, text, width, wrappedRow)
import Element.Background as Background
import Element.Border as Border
import Element.Font as Font
import Element.Input as Input
import Element.Region as Region
import Html exposing (Html)
import Maybe.Extra exposing (values)
import Random exposing (generate)
import Task

Expand All @@ -21,14 +19,17 @@ import Task
-- CONSTANTS


cvssv3MinimumScore : Float
cvssv3MinimumScore =
0.0


cvssv3MaximumScore : Float
cvssv3MaximumScore =
10.0


firstOrgCvssPrefix : String
firstOrgCvssPrefix =
"https://www.first.org/cvss/calculator/3.1#"

Expand All @@ -52,6 +53,7 @@ lightGrey =
-- MAIN


main : Program () Model Msg
main =
Browser.document
{ init = init
Expand Down Expand Up @@ -84,11 +86,6 @@ init _ =
)


initVector : Vector
initVector =
Vector AvNetwork AcLow PrNone UiNone SUnchanged CNone INone ANone



-- SUBSCRIPTIONS

Expand Down

0 comments on commit 193c3ba

Please sign in to comment.