trestle.tasks.xlsx_to_oscal_poam
trestle.tasks.xlsx_to_oscal_poam ¤
Transform POAM spreadsheet to OSCAL POAM JSON format.
Attributes¤
logger = logging.getLogger(__name__) module-attribute ¤
Classes¤
PoamBuilder ¤
Builder class for constructing OSCAL POAM objects from spreadsheet data.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
Methods:¤
__init__(timestamp, validator) ¤
Initialize builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timestamp | str | ISO timestamp for metadata | required |
validator | PoamValidator | PoamValidator instance | required |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
491 492 493 494 495 496 497 498 499 500 | |
create_observation(poam_id, row_data, helper) ¤
Create Observation from row data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poam_id | str | POAM ID | required |
row_data | Dict[str, Any] | Row data dictionary | required |
helper | PoamXlsxHelper | PoamXlsxHelper instance | required |
Returns:
| Type | Description |
|---|---|
Observation | Observation object |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
create_poam_item(poam_id, row_data) ¤
Create PoamItem from row data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poam_id | str | POAM ID | required |
row_data | Dict[str, Any] | Row data dictionary | required |
Returns:
| Type | Description |
|---|---|
PoamItem | PoamItem object |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
create_risk(poam_id, row_data, helper) ¤
Create Risk from row data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poam_id | str | POAM ID | required |
row_data | Dict[str, Any] | Row data dictionary | required |
helper | PoamXlsxHelper | PoamXlsxHelper instance | required |
Returns:
| Type | Description |
|---|---|
Risk | Risk object |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 | |
link_objects(poam_item, observation, risk) ¤
Link POAM objects together via UUID references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
poam_item | PoamItem | PoamItem to link | required |
observation | Observation | Observation to link | required |
risk | Risk | Risk to link | required |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
PoamValidator ¤
Validate POAM spreadsheet data before transformation.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
Attributes¤
CONTROL_PATTERN = re.compile('^[A-Z]{2}-\\d+(\\(\\d+\\))?$') class-attribute instance-attribute ¤
VALID_RISK_RATINGS = ['Low', 'Moderate', 'High', 'N/A'] class-attribute instance-attribute ¤
VALID_YES_NO_PENDING = ['Yes', 'No', 'Pending'] class-attribute instance-attribute ¤
errors = [] instance-attribute ¤
validate_mode = validate_mode instance-attribute ¤
warnings = [] instance-attribute ¤
Methods:¤
__init__(validate_mode='warn') ¤
Initialize validator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
validate_mode | str | 'on' (fail on error), 'warn' (log warnings), or 'off' (skip validation) | 'warn' |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
102 103 104 105 106 107 108 109 110 111 | |
log_validation_results() ¤
Log validation results based on validation mode.
Returns:
| Type | Description |
|---|---|
bool | True if validation passed or mode is 'warn'/'off', False if errors in 'on' mode |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
parse_controls(controls_str) ¤
Parse and validate control IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
controls_str | str | Comma/space-separated control IDs like "AC-1, AC-2, SC-7(5)" | required |
Returns:
| Type | Description |
|---|---|
List[str] | List of validated control IDs |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
validate_row(row_num, row_data) ¤
Validate a single row of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
row_num | int | Row number in spreadsheet | required |
row_data | Dict[str, Any] | Dictionary of column_name -> value | required |
Returns:
| Type | Description |
|---|---|
List[str] | List of validation error messages |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
PoamXlsxHelper ¤
Helper class for reading POAM spreadsheet templates.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
Attributes¤
ADJUSTED_RISK_RATING = 'Adjusted Risk Rating' class-attribute instance-attribute ¤
ASSET_IDENTIFIER = 'Asset Identifier' class-attribute instance-attribute ¤
AUTO_APPROVE = 'Auto-Approve' class-attribute instance-attribute ¤
BOD_22_01_DUE_DATE = 'Binding Operational Directive 22-01 Due Date' class-attribute instance-attribute ¤
BOD_22_01_TRACKING = 'Binding Operational Directive 22-01 tracking' class-attribute instance-attribute ¤
COMMENTS = 'Comments' class-attribute instance-attribute ¤
CONTROLS = 'Controls' class-attribute instance-attribute ¤
CVE = 'CVE' class-attribute instance-attribute ¤
DEVIATION_RATIONALE = 'Deviation Rationale' class-attribute instance-attribute ¤
FALSE_POSITIVE = 'False Positive' class-attribute instance-attribute ¤
LAST_VENDOR_CHECKIN_DATE = 'Last Vendor Check-in Date' class-attribute instance-attribute ¤
MILESTONE_CHANGES = 'Milestone Changes' class-attribute instance-attribute ¤
OPERATIONAL_REQUIREMENT = 'Operational Requirement' class-attribute instance-attribute ¤
ORIGINAL_DETECTION_DATE = 'Original Detection Date' class-attribute instance-attribute ¤
ORIGINAL_RISK_RATING = 'Original Risk Rating' class-attribute instance-attribute ¤
OVERALL_REMEDIATION_PLAN = 'Overall Remediation Plan' class-attribute instance-attribute ¤
PLANNED_MILESTONES = 'Planned Milestones' class-attribute instance-attribute ¤
POAM_ID = 'POAM ID' class-attribute instance-attribute ¤
POINT_OF_CONTACT = 'Point of Contact' class-attribute instance-attribute ¤
RESOURCES_REQUIRED = 'Resources Required' class-attribute instance-attribute ¤
RISK_ADJUSTMENT = 'Risk Adjustment' class-attribute instance-attribute ¤
SCHEDULED_COMPLETION_DATE = 'Scheduled Completion Date' class-attribute instance-attribute ¤
SERVICE_NAME = 'Service Name' class-attribute instance-attribute ¤
STATUS_DATE = 'Status Date' class-attribute instance-attribute ¤
SUPPORTING_DOCUMENTS = 'Supporting Documents' class-attribute instance-attribute ¤
VENDOR_DEPENDENCY = 'Vendor Dependency' class-attribute instance-attribute ¤
VENDOR_DEPENDENT_PRODUCT_NAME = 'Vendor Dependent Product Name' class-attribute instance-attribute ¤
WEAKNESS_DESCRIPTION = 'Weakness Description' class-attribute instance-attribute ¤
WEAKNESS_DETECTOR_SOURCE = 'Weakness Detector Source' class-attribute instance-attribute ¤
WEAKNESS_NAME = 'Weakness Name' class-attribute instance-attribute ¤
WEAKNESS_SOURCE_IDENTIFIER = 'Weakness Source Identifier' class-attribute instance-attribute ¤
Methods:¤
__init__() ¤
Initialize helper.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
248 249 250 251 252 | |
load(xlsx_path, sheet_name='Open POA&M Items') ¤
Load spreadsheet file and map columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xlsx_path | Path | Path to spreadsheet file | required |
sheet_name | str | Name of worksheet to load | 'Open POA&M Items' |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If file doesn't exist |
KeyError | If worksheet doesn't exist |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | |
parse_date(date_value) ¤
Parse spreadsheet date to datetime with timezone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
date_value | Any | Spreadsheet date (datetime object or string) | required |
Returns:
| Type | Description |
|---|---|
Optional[datetime] | datetime with UTC timezone or None |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
parse_milestones(milestones_str) ¤
Parse milestone text into structured format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
milestones_str | str | Milestone text (may contain multiple milestones) | required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]] | List of milestone dictionaries with 'title', 'description', optional 'timing' |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | |
row_generator() ¤
Generate row numbers and data dictionaries for data rows.
Yields:
| Type | Description |
|---|---|
Tuple[int, Dict[str, Any]] | Tuple of (row_number, row_data_dict) |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | |
UUIDManager ¤
Manage deterministic UUID generation for POAM objects.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
Attributes¤
NAMESPACE = uuid.UUID('e8d8efc6-c23e-4e3e-a2e8-bc8fc08ff6c3') class-attribute instance-attribute ¤
Methods:¤
actor_uuid(actor_name) staticmethod ¤
Generate deterministic UUID for Origin Actor.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
84 85 86 87 | |
observation_uuid(poam_id) staticmethod ¤
Generate deterministic UUID for Observation from POAM ID.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
69 70 71 72 | |
poam_item_uuid(poam_id) staticmethod ¤
Generate deterministic UUID for PoamItem from POAM ID.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
64 65 66 67 | |
remediation_uuid(poam_id) staticmethod ¤
Generate deterministic UUID for Response (remediation) from POAM ID.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
89 90 91 92 | |
risk_uuid(poam_id) staticmethod ¤
Generate deterministic UUID for Risk from POAM ID.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
74 75 76 77 | |
task_uuid(poam_id, milestone_index) staticmethod ¤
Generate deterministic UUID for Task (milestone) from POAM ID + index.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
79 80 81 82 | |
XlsxToOscalPoam ¤
Bases: TaskBase
flowchart TD
trestle.tasks.xlsx_to_oscal_poam.XlsxToOscalPoam[XlsxToOscalPoam]
trestle.tasks.base_task.TaskBase[TaskBase]
trestle.tasks.base_task.TaskBase --> trestle.tasks.xlsx_to_oscal_poam.XlsxToOscalPoam
click trestle.tasks.xlsx_to_oscal_poam.XlsxToOscalPoam href "" "trestle.tasks.xlsx_to_oscal_poam.XlsxToOscalPoam"
click trestle.tasks.base_task.TaskBase href "" "trestle.tasks.base_task.TaskBase"
Transform POAM spreadsheet to OSCAL POAM JSON.
This task reads a POAM spreadsheet template (specifically the "Open POA&M Items" worksheet) and transforms each row into an OSCAL Plan of Action and Milestones (POAM) JSON file.
Each spreadsheet row creates three linked OSCAL objects: 1. PoamItem: The main weakness/issue description 2. Observation: Details about when/how the weakness was detected 3. Risk: Risk assessment, remediation plan, and milestones
Configuration Example
[task.xlsx-to-oscal-poam] xlsx-file = POAM-Template.xlsx output-dir = output/ title = MySystem POA&M version = 1.0
Spreadsheet Requirements
- Must use POAM template structure
- Headers at row 5
- Data starts at row 6
- Required columns: POAM ID, Weakness Name, Weakness Description, Controls
See Also
- docs/tutorials/task.xlsx-to-oscal-poam.md
- OSCAL POAM specification
Source code in trestle/tasks/xlsx_to_oscal_poam.py
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | |
Attributes¤
name = 'xlsx-to-oscal-poam' class-attribute instance-attribute ¤
Methods:¤
__init__(config_object) ¤
Initialize trestle task xlsx-to-oscal-poam.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_object | Optional[SectionProxy] | Config section associated with the task. | required |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
826 827 828 829 830 831 832 833 834 | |
configure() ¤
Configure the task.
Returns:
| Type | Description |
|---|---|
bool | True if configuration successful, False otherwise |
Source code in trestle/tasks/xlsx_to_oscal_poam.py
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 | |
execute() ¤
Provide an executed outcome.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
974 975 976 977 978 979 980 | |
print_info() ¤
Print the help string.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 | |
set_timestamp(timestamp) ¤
Set the timestamp.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
836 837 838 | |
simulate() ¤
Provide a simulated outcome.
Source code in trestle/tasks/xlsx_to_oscal_poam.py
970 971 972 | |
handler: python