Пример #1
0
        public static CvssV3TemporalScore FromVectorString(string vectorString)
        {
            vectorString = vectorString ?? throw new ArgumentNullException(nameof(vectorString));
            if (string.IsNullOrWhiteSpace(vectorString) ||
                !Regex.IsMatch(vectorString, "^CVSS:3\\.0\\/((AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]|E:[XUPFH]|RL:[XOTWU]|RC:[XURC]|[CIA]R:[XLMH]|MAV:[XNALP]|MAC:[XLH]|MPR:[XUNLH]|MUI:[XNR]|MS:[XUC]|M[CIA]:[XNLH])\\/)*(AV:[NALP]|AC:[LH]|PR:[UNLH]|UI:[NR]|S:[UC]|[CIA]:[NLH]|E:[XUPFH]|RL:[XOTWU]|RC:[XURC]|[CIA]R:[XLMH]|MAV:[XNALP]|MAC:[XLH]|MPR:[XUNLH]|MUI:[XNR]|MS:[XUC]|M[CIA]:[XNLH])$"))
            {
                throw new ArgumentException("Not a valid CVSS V3 vector string, invalid format", nameof(vectorString));
            }

            var cvssV3TemporalScore = new CvssV3TemporalScore
            {
                ExploitCodeMaturity = VectorStringParser <CvssV3Enums.ExploitCodeMaturity> .Parse(vectorString),
                RemediationLevel    = VectorStringParser <CvssV3Enums.RemediationLevel> .Parse(vectorString),
                ReportConfidence    = VectorStringParser <CvssV3Enums.ReportConfidence> .Parse(vectorString),
            };

            return(cvssV3TemporalScore);
        }
Пример #2
0
        public static CvssV3TemporalScore FromCvssV2TemporalScore(CvssV2TemporalScore cvssV2TemporalScore)
        {
            var cvssV3TemporalScore = new CvssV3TemporalScore();

            switch (cvssV2TemporalScore.Exploitability)
            {
            case CvssV2Enums.Exploitability.NotDefined:
                cvssV3TemporalScore.ExploitCodeMaturity = CvssV3Enums.ExploitCodeMaturity.NotDefined;
                break;

            case CvssV2Enums.Exploitability.Unproven:
                cvssV3TemporalScore.ExploitCodeMaturity = CvssV3Enums.ExploitCodeMaturity.Unproven;
                break;

            case CvssV2Enums.Exploitability.ProofOfConcept:
                cvssV3TemporalScore.ExploitCodeMaturity = CvssV3Enums.ExploitCodeMaturity.ProofOfConcept;
                break;

            case CvssV2Enums.Exploitability.Functional:
                cvssV3TemporalScore.ExploitCodeMaturity = CvssV3Enums.ExploitCodeMaturity.Functional;
                break;

            case CvssV2Enums.Exploitability.High:
                cvssV3TemporalScore.ExploitCodeMaturity = CvssV3Enums.ExploitCodeMaturity.High;
                break;
            }

            switch (cvssV2TemporalScore.RemediationLevel)
            {
            case CvssV2Enums.RemediationLevel.NotDefined:
                cvssV3TemporalScore.RemediationLevel = CvssV3Enums.RemediationLevel.NotDefined;
                break;

            case CvssV2Enums.RemediationLevel.OfficialFix:
                cvssV3TemporalScore.RemediationLevel = CvssV3Enums.RemediationLevel.OfficialFix;
                break;

            case CvssV2Enums.RemediationLevel.TemporaryFix:
                cvssV3TemporalScore.RemediationLevel = CvssV3Enums.RemediationLevel.TemporaryFix;
                break;

            case CvssV2Enums.RemediationLevel.Workaround:
                cvssV3TemporalScore.RemediationLevel = CvssV3Enums.RemediationLevel.Workaround;
                break;

            case CvssV2Enums.RemediationLevel.Unavailable:
                cvssV3TemporalScore.RemediationLevel = CvssV3Enums.RemediationLevel.Unavailable;
                break;
            }

            switch (cvssV2TemporalScore.ReportConfidence)
            {
            case CvssV2Enums.ReportConfidence.NotDefined:
                cvssV3TemporalScore.ReportConfidence = CvssV3Enums.ReportConfidence.NotDefined;
                break;

            case CvssV2Enums.ReportConfidence.Confirmed:
                cvssV3TemporalScore.ReportConfidence = CvssV3Enums.ReportConfidence.Confirmed;
                break;

            case CvssV2Enums.ReportConfidence.Uncorroborated:
                cvssV3TemporalScore.ReportConfidence = CvssV3Enums.ReportConfidence.Reasonable;
                break;

            case CvssV2Enums.ReportConfidence.Unconfirmed:
                cvssV3TemporalScore.ReportConfidence = CvssV3Enums.ReportConfidence.Unknown;
                break;
            }

            return(cvssV3TemporalScore);
        }
Пример #3
0
 public CvssV3Score()
 {
     BaseScore          = new CvssV3BaseScore();
     TemporalScore      = new CvssV3TemporalScore();
     EnvironmentalScore = new CvssV3EnvironmentalScore();
 }