Coverage for lobster/common/raw_policy.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2026-09-22 04:43 +0000

1#!/usr/bin/env python3 

2# 

3# LOBSTER - Lightweight Open BMW Software Traceability Evidence Report 

4# Copyright (C) 2026 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 

5# 

6# This program is free software: you can redistribute it and/or modify 

7# it under the terms of the GNU Affero General Public License as 

8# published by the Free Software Foundation, either version 3 of the 

9# License, or (at your option) any later version. 

10# 

11# This program is distributed in the hope that it will be useful, but 

12# WITHOUT ANY WARRANTY; without even the implied warranty of 

13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

14# Affero General Public License for more details. 

15# 

16# You should have received a copy of the GNU Affero General Public 

17# License along with this program. If not, see 

18# <https://www.gnu.org/licenses/>. 

19 

20# Format-agnostic, unvalidated intermediate representation of a tracing 

21# policy, produced by a format-specific reader (e.g. 

22# lobster/common/parser.py) and consumed by 

23# lobster/common/policy_builder.py. 

24 

25from dataclasses import dataclass, field 

26from typing import List 

27 

28from lobster.common.location import Location 

29 

30 

31@dataclass 

32class RawSource: 

33 file: str 

34 loc: Location 

35 

36 

37@dataclass 

38class RawTraceTo: 

39 target: str 

40 loc: Location 

41 

42 

43@dataclass 

44class RawRequiresCandidate: 

45 name: str 

46 loc: Location 

47 

48 

49@dataclass 

50class RawLevel: 

51 name: str 

52 name_loc: Location 

53 kind: str 

54 source: List[RawSource] = field(default_factory=list) 

55 trace_to: List[RawTraceTo] = field(default_factory=list) 

56 # One entry per "requires" directive; each entry is the OR-group of 

57 # candidates (one "requires: A or B;" line == one entry). 

58 requires: List[List[RawRequiresCandidate]] = field(default_factory=list) 

59 

60 

61@dataclass 

62class RawPolicy: 

63 levels: List[RawLevel] = field(default_factory=list)