cvss_vulnerability_scoring 1.0.0
cvss_vulnerability_scoring: ^1.0.0 copied to clipboard
CVSS v2.0, v3.0, and v3.1 score calculation and parsing for Dart
// Copyright 2026 punExperiment
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import 'package:cvss_vulnerability_scoring/cvss_vulnerability_scoring.dart';
void main() {
// Parse CVSS vector, version will be automatically detected by the library
final v3_1 = CVSS.fromString('CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H');
print('Vector: $v3_1'); // CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
print('Score: ${v3_1.calculateBaseScore()}'); // 9.8
print('Severity: ${v3_1.baseSeverityRating().name}'); // critical
// Or construct a specific version directly
final v2 = CVSSv20(
accessVector: AccessVector.network,
accessComplexity: AccessComplexity.high,
authentication: Authentication.multiple,
confidentialityImpact: ConfidentialityImpactV2.none,
integrityImpact: IntegrityImpactV2.partial,
availabilityImpact: AvailabilityImpactV2.complete,
);
print('\nCVSS v2.0: $v2'); // CVSS:2.0/AV:N/AC:H/Au:M/C:N/I:P/A:C
print('Score: ${v2.calculateBaseScore()}'); // 5.3
print('Severity: ${v2.baseSeverityRating().name}'); // medium
}