spdx30.py 258 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593
  1. #! /usr/bin/env python3
  2. #
  3. # Generated Python bindings from a SHACL model
  4. #
  5. # This file was automatically generated by shacl2code. DO NOT MANUALLY MODIFY IT
  6. #
  7. # SPDX-License-Identifier: MIT
  8. import functools
  9. import hashlib
  10. import json
  11. import re
  12. import sys
  13. import threading
  14. import time
  15. from contextlib import contextmanager
  16. from datetime import datetime, timezone, timedelta
  17. from enum import Enum
  18. from abc import ABC, abstractmethod
  19. def check_type(obj, types):
  20. if not isinstance(obj, types):
  21. if isinstance(types, (list, tuple)):
  22. raise TypeError(
  23. f"Value must be one of type: {', '.join(t.__name__ for t in types)}. Got {type(obj)}"
  24. )
  25. raise TypeError(f"Value must be of type {types.__name__}. Got {type(obj)}")
  26. class Property(ABC):
  27. """
  28. A generic SHACL object property. The different types will derive from this
  29. class
  30. """
  31. def __init__(self, *, pattern=None):
  32. self.pattern = pattern
  33. def init(self):
  34. return None
  35. def validate(self, value):
  36. check_type(value, self.VALID_TYPES)
  37. if self.pattern is not None and not re.search(
  38. self.pattern, self.to_string(value)
  39. ):
  40. raise ValueError(
  41. f"Value is not correctly formatted. Got '{self.to_string(value)}'"
  42. )
  43. def set(self, value):
  44. return value
  45. def check_min_count(self, value, min_count):
  46. return min_count == 1
  47. def check_max_count(self, value, max_count):
  48. return max_count == 1
  49. def elide(self, value):
  50. return value is None
  51. def walk(self, value, callback, path):
  52. callback(value, path)
  53. def iter_objects(self, value, recursive, visited):
  54. return []
  55. def link_prop(self, value, objectset, missing, visited):
  56. return value
  57. def to_string(self, value):
  58. return str(value)
  59. @abstractmethod
  60. def encode(self, encoder, value, state):
  61. pass
  62. @abstractmethod
  63. def decode(self, decoder, *, objectset=None):
  64. pass
  65. class StringProp(Property):
  66. """
  67. A scalar string property for an SHACL object
  68. """
  69. VALID_TYPES = str
  70. def set(self, value):
  71. return str(value)
  72. def encode(self, encoder, value, state):
  73. encoder.write_string(value)
  74. def decode(self, decoder, *, objectset=None):
  75. return decoder.read_string()
  76. class AnyURIProp(StringProp):
  77. def encode(self, encoder, value, state):
  78. encoder.write_iri(value)
  79. def decode(self, decoder, *, objectset=None):
  80. return decoder.read_iri()
  81. class DateTimeProp(Property):
  82. """
  83. A Date/Time Object with optional timezone
  84. """
  85. VALID_TYPES = datetime
  86. UTC_FORMAT_STR = "%Y-%m-%dT%H:%M:%SZ"
  87. REGEX = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})?$"
  88. def set(self, value):
  89. return self._normalize(value)
  90. def encode(self, encoder, value, state):
  91. encoder.write_datetime(self.to_string(value))
  92. def decode(self, decoder, *, objectset=None):
  93. s = decoder.read_datetime()
  94. if s is None:
  95. return None
  96. v = self.from_string(s)
  97. return self._normalize(v)
  98. def _normalize(self, value):
  99. if value.utcoffset() is None:
  100. value = value.astimezone()
  101. offset = value.utcoffset()
  102. seconds = offset % timedelta(minutes=-1 if offset.total_seconds() < 0 else 1)
  103. if seconds:
  104. offset = offset - seconds
  105. value = value.replace(tzinfo=timezone(offset))
  106. value = value.replace(microsecond=0)
  107. return value
  108. def to_string(self, value):
  109. value = self._normalize(value)
  110. if value.tzinfo == timezone.utc:
  111. return value.strftime(self.UTC_FORMAT_STR)
  112. return value.isoformat()
  113. def from_string(self, value):
  114. if not re.match(self.REGEX, value):
  115. raise ValueError(f"'{value}' is not a correctly formatted datetime")
  116. if "Z" in value:
  117. d = datetime(
  118. *(time.strptime(value, self.UTC_FORMAT_STR)[0:6]),
  119. tzinfo=timezone.utc,
  120. )
  121. else:
  122. d = datetime.fromisoformat(value)
  123. return self._normalize(d)
  124. class DateTimeStampProp(DateTimeProp):
  125. """
  126. A Date/Time Object with required timestamp
  127. """
  128. REGEX = r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})$"
  129. class IntegerProp(Property):
  130. VALID_TYPES = int
  131. def set(self, value):
  132. return int(value)
  133. def encode(self, encoder, value, state):
  134. encoder.write_integer(value)
  135. def decode(self, decoder, *, objectset=None):
  136. return decoder.read_integer()
  137. class PositiveIntegerProp(IntegerProp):
  138. def validate(self, value):
  139. super().validate(value)
  140. if value < 1:
  141. raise ValueError(f"Value must be >=1. Got {value}")
  142. class NonNegativeIntegerProp(IntegerProp):
  143. def validate(self, value):
  144. super().validate(value)
  145. if value < 0:
  146. raise ValueError(f"Value must be >= 0. Got {value}")
  147. class BooleanProp(Property):
  148. VALID_TYPES = bool
  149. def set(self, value):
  150. return bool(value)
  151. def encode(self, encoder, value, state):
  152. encoder.write_bool(value)
  153. def decode(self, decoder, *, objectset=None):
  154. return decoder.read_bool()
  155. class FloatProp(Property):
  156. VALID_TYPES = (float, int)
  157. def set(self, value):
  158. return float(value)
  159. def encode(self, encoder, value, state):
  160. encoder.write_float(value)
  161. def decode(self, decoder, *, objectset=None):
  162. return decoder.read_float()
  163. class IRIProp(Property):
  164. def __init__(self, context=[], *, pattern=None):
  165. super().__init__(pattern=pattern)
  166. self.context = context
  167. def compact(self, value):
  168. for iri, compact in self.context:
  169. if value == iri:
  170. return compact
  171. return None
  172. def expand(self, value):
  173. for iri, compact in self.context:
  174. if value == compact:
  175. return iri
  176. return None
  177. def iri_values(self):
  178. return (iri for iri, _ in self.context)
  179. class ObjectProp(IRIProp):
  180. """
  181. A scalar SHACL object property of a SHACL object
  182. """
  183. def __init__(self, cls, required, context=[]):
  184. super().__init__(context)
  185. self.cls = cls
  186. self.required = required
  187. def init(self):
  188. if self.required and not self.cls.IS_ABSTRACT:
  189. return self.cls()
  190. return None
  191. def validate(self, value):
  192. check_type(value, (self.cls, str))
  193. def walk(self, value, callback, path):
  194. if value is None:
  195. return
  196. if not isinstance(value, str):
  197. value.walk(callback, path)
  198. else:
  199. callback(value, path)
  200. def iter_objects(self, value, recursive, visited):
  201. if value is None or isinstance(value, str):
  202. return
  203. if value not in visited:
  204. visited.add(value)
  205. yield value
  206. if recursive:
  207. for c in value.iter_objects(recursive=True, visited=visited):
  208. yield c
  209. def encode(self, encoder, value, state):
  210. if value is None:
  211. raise ValueError("Object cannot be None")
  212. if isinstance(value, str):
  213. encoder.write_iri(value, self.compact(value))
  214. return
  215. return value.encode(encoder, state)
  216. def decode(self, decoder, *, objectset=None):
  217. iri = decoder.read_iri()
  218. if iri is None:
  219. return self.cls.decode(decoder, objectset=objectset)
  220. iri = self.expand(iri) or iri
  221. if objectset is None:
  222. return iri
  223. obj = objectset.find_by_id(iri)
  224. if obj is None:
  225. return iri
  226. self.validate(obj)
  227. return obj
  228. def link_prop(self, value, objectset, missing, visited):
  229. if value is None:
  230. return value
  231. if isinstance(value, str):
  232. o = objectset.find_by_id(value)
  233. if o is not None:
  234. self.validate(o)
  235. return o
  236. if missing is not None:
  237. missing.add(value)
  238. return value
  239. # De-duplicate IDs
  240. if value._id:
  241. value = objectset.find_by_id(value._id, value)
  242. self.validate(value)
  243. value.link_helper(objectset, missing, visited)
  244. return value
  245. class ListProxy(object):
  246. def __init__(self, prop, data=None):
  247. if data is None:
  248. self.__data = []
  249. else:
  250. self.__data = data
  251. self.__prop = prop
  252. def append(self, value):
  253. self.__prop.validate(value)
  254. self.__data.append(self.__prop.set(value))
  255. def insert(self, idx, value):
  256. self.__prop.validate(value)
  257. self.__data.insert(idx, self.__prop.set(value))
  258. def extend(self, items):
  259. for i in items:
  260. self.append(i)
  261. def sort(self, *args, **kwargs):
  262. self.__data.sort(*args, **kwargs)
  263. def __getitem__(self, key):
  264. return self.__data[key]
  265. def __setitem__(self, key, value):
  266. if isinstance(key, slice):
  267. for v in value:
  268. self.__prop.validate(v)
  269. self.__data[key] = [self.__prop.set(v) for v in value]
  270. else:
  271. self.__prop.validate(value)
  272. self.__data[key] = self.__prop.set(value)
  273. def __delitem__(self, key):
  274. del self.__data[key]
  275. def __contains__(self, item):
  276. return item in self.__data
  277. def __iter__(self):
  278. return iter(self.__data)
  279. def __len__(self):
  280. return len(self.__data)
  281. def __str__(self):
  282. return str(self.__data)
  283. def __repr__(self):
  284. return repr(self.__data)
  285. def __eq__(self, other):
  286. if isinstance(other, ListProxy):
  287. return self.__data == other.__data
  288. return self.__data == other
  289. class ListProp(Property):
  290. """
  291. A list of SHACL properties
  292. """
  293. VALID_TYPES = (list, ListProxy)
  294. def __init__(self, prop):
  295. super().__init__()
  296. self.prop = prop
  297. def init(self):
  298. return ListProxy(self.prop)
  299. def validate(self, value):
  300. super().validate(value)
  301. for i in value:
  302. self.prop.validate(i)
  303. def set(self, value):
  304. if isinstance(value, ListProxy):
  305. return value
  306. return ListProxy(self.prop, [self.prop.set(d) for d in value])
  307. def check_min_count(self, value, min_count):
  308. check_type(value, ListProxy)
  309. return len(value) >= min_count
  310. def check_max_count(self, value, max_count):
  311. check_type(value, ListProxy)
  312. return len(value) <= max_count
  313. def elide(self, value):
  314. check_type(value, ListProxy)
  315. return len(value) == 0
  316. def walk(self, value, callback, path):
  317. callback(value, path)
  318. for idx, v in enumerate(value):
  319. self.prop.walk(v, callback, path + [f"[{idx}]"])
  320. def iter_objects(self, value, recursive, visited):
  321. for v in value:
  322. for c in self.prop.iter_objects(v, recursive, visited):
  323. yield c
  324. def link_prop(self, value, objectset, missing, visited):
  325. if isinstance(value, ListProxy):
  326. data = [self.prop.link_prop(v, objectset, missing, visited) for v in value]
  327. else:
  328. data = [self.prop.link_prop(v, objectset, missing, visited) for v in value]
  329. return ListProxy(self.prop, data=data)
  330. def encode(self, encoder, value, state):
  331. check_type(value, ListProxy)
  332. with encoder.write_list() as list_s:
  333. for v in value:
  334. with list_s.write_list_item() as item_s:
  335. self.prop.encode(item_s, v, state)
  336. def decode(self, decoder, *, objectset=None):
  337. data = []
  338. for val_d in decoder.read_list():
  339. v = self.prop.decode(val_d, objectset=objectset)
  340. self.prop.validate(v)
  341. data.append(v)
  342. return ListProxy(self.prop, data=data)
  343. class EnumProp(IRIProp):
  344. VALID_TYPES = str
  345. def __init__(self, values, *, pattern=None):
  346. super().__init__(values, pattern=pattern)
  347. def validate(self, value):
  348. super().validate(value)
  349. valid_values = self.iri_values()
  350. if value not in valid_values:
  351. raise ValueError(
  352. f"'{value}' is not a valid value. Choose one of {' '.join(valid_values)}"
  353. )
  354. def encode(self, encoder, value, state):
  355. encoder.write_enum(value, self, self.compact(value))
  356. def decode(self, decoder, *, objectset=None):
  357. v = decoder.read_enum(self)
  358. return self.expand(v) or v
  359. class NodeKind(Enum):
  360. BlankNode = 1
  361. IRI = 2
  362. BlankNodeOrIRI = 3
  363. def is_IRI(s):
  364. if not isinstance(s, str):
  365. return False
  366. if s.startswith("_:"):
  367. return False
  368. if ":" not in s:
  369. return False
  370. return True
  371. def is_blank_node(s):
  372. if not isinstance(s, str):
  373. return False
  374. if not s.startswith("_:"):
  375. return False
  376. return True
  377. def register(type_iri, *, compact_type=None, abstract=False):
  378. def add_class(key, c):
  379. assert (
  380. key not in SHACLObject.CLASSES
  381. ), f"{key} already registered to {SHACLObject.CLASSES[key].__name__}"
  382. SHACLObject.CLASSES[key] = c
  383. def decorator(c):
  384. global NAMED_INDIVIDUALS
  385. assert issubclass(
  386. c, SHACLObject
  387. ), f"{c.__name__} is not derived from SHACLObject"
  388. c._OBJ_TYPE = type_iri
  389. c.IS_ABSTRACT = abstract
  390. add_class(type_iri, c)
  391. c._OBJ_COMPACT_TYPE = compact_type
  392. if compact_type:
  393. add_class(compact_type, c)
  394. NAMED_INDIVIDUALS |= set(c.NAMED_INDIVIDUALS.values())
  395. # Registration is deferred until the first instance of class is created
  396. # so that it has access to any other defined class
  397. c._NEEDS_REG = True
  398. return c
  399. return decorator
  400. register_lock = threading.Lock()
  401. NAMED_INDIVIDUALS = set()
  402. @functools.total_ordering
  403. class SHACLObject(object):
  404. CLASSES = {}
  405. NODE_KIND = NodeKind.BlankNodeOrIRI
  406. ID_ALIAS = None
  407. IS_ABSTRACT = True
  408. def __init__(self, **kwargs):
  409. if self._is_abstract():
  410. raise NotImplementedError(
  411. f"{self.__class__.__name__} is abstract and cannot be implemented"
  412. )
  413. with register_lock:
  414. cls = self.__class__
  415. if cls._NEEDS_REG:
  416. cls._OBJ_PROPERTIES = {}
  417. cls._OBJ_IRIS = {}
  418. cls._register_props()
  419. cls._NEEDS_REG = False
  420. self.__dict__["_obj_data"] = {}
  421. self.__dict__["_obj_metadata"] = {}
  422. for iri, prop, _, _, _, _ in self.__iter_props():
  423. self.__dict__["_obj_data"][iri] = prop.init()
  424. for k, v in kwargs.items():
  425. setattr(self, k, v)
  426. def _is_abstract(self):
  427. return self.__class__.IS_ABSTRACT
  428. @classmethod
  429. def _register_props(cls):
  430. cls._add_property("_id", StringProp(), iri="@id")
  431. @classmethod
  432. def _add_property(
  433. cls,
  434. pyname,
  435. prop,
  436. iri,
  437. min_count=None,
  438. max_count=None,
  439. compact=None,
  440. ):
  441. if pyname in cls._OBJ_IRIS:
  442. raise KeyError(f"'{pyname}' is already defined for '{cls.__name__}'")
  443. if iri in cls._OBJ_PROPERTIES:
  444. raise KeyError(f"'{iri}' is already defined for '{cls.__name__}'")
  445. while hasattr(cls, pyname):
  446. pyname = pyname + "_"
  447. pyname = sys.intern(pyname)
  448. iri = sys.intern(iri)
  449. cls._OBJ_IRIS[pyname] = iri
  450. cls._OBJ_PROPERTIES[iri] = (prop, min_count, max_count, pyname, compact)
  451. def __setattr__(self, name, value):
  452. if name == self.ID_ALIAS:
  453. self["@id"] = value
  454. return
  455. try:
  456. iri = self._OBJ_IRIS[name]
  457. self[iri] = value
  458. except KeyError:
  459. raise AttributeError(
  460. f"'{name}' is not a valid property of {self.__class__.__name__}"
  461. )
  462. def __getattr__(self, name):
  463. if name in self._OBJ_IRIS:
  464. return self.__dict__["_obj_data"][self._OBJ_IRIS[name]]
  465. if name == self.ID_ALIAS:
  466. return self.__dict__["_obj_data"]["@id"]
  467. if name == "_metadata":
  468. return self.__dict__["_obj_metadata"]
  469. if name == "_IRI":
  470. return self._OBJ_IRIS
  471. if name == "TYPE":
  472. return self.__class__._OBJ_TYPE
  473. if name == "COMPACT_TYPE":
  474. return self.__class__._OBJ_COMPACT_TYPE
  475. raise AttributeError(
  476. f"'{name}' is not a valid property of {self.__class__.__name__}"
  477. )
  478. def __delattr__(self, name):
  479. if name == self.ID_ALIAS:
  480. del self["@id"]
  481. return
  482. try:
  483. iri = self._OBJ_IRIS[name]
  484. del self[iri]
  485. except KeyError:
  486. raise AttributeError(
  487. f"'{name}' is not a valid property of {self.__class__.__name__}"
  488. )
  489. def __get_prop(self, iri):
  490. if iri not in self._OBJ_PROPERTIES:
  491. raise KeyError(
  492. f"'{iri}' is not a valid property of {self.__class__.__name__}"
  493. )
  494. return self._OBJ_PROPERTIES[iri]
  495. def __iter_props(self):
  496. for iri, v in self._OBJ_PROPERTIES.items():
  497. yield iri, *v
  498. def __getitem__(self, iri):
  499. return self.__dict__["_obj_data"][iri]
  500. def __setitem__(self, iri, value):
  501. if iri == "@id":
  502. if self.NODE_KIND == NodeKind.BlankNode:
  503. if not is_blank_node(value):
  504. raise ValueError(
  505. f"{self.__class__.__name__} ({id(self)}) can only have local reference. Property '{iri}' cannot be set to '{value}' and must start with '_:'"
  506. )
  507. elif self.NODE_KIND == NodeKind.IRI:
  508. if not is_IRI(value):
  509. raise ValueError(
  510. f"{self.__class__.__name__} ({id(self)}) can only have an IRI value. Property '{iri}' cannot be set to '{value}'"
  511. )
  512. else:
  513. if not is_blank_node(value) and not is_IRI(value):
  514. raise ValueError(
  515. f"{self.__class__.__name__} ({id(self)}) Has invalid Property '{iri}' '{value}'. Must be a blank node or IRI"
  516. )
  517. prop, _, _, _, _ = self.__get_prop(iri)
  518. prop.validate(value)
  519. self.__dict__["_obj_data"][iri] = prop.set(value)
  520. def __delitem__(self, iri):
  521. prop, _, _, _, _ = self.__get_prop(iri)
  522. self.__dict__["_obj_data"][iri] = prop.init()
  523. def __iter__(self):
  524. return self._OBJ_PROPERTIES.keys()
  525. def walk(self, callback, path=None):
  526. """
  527. Walk object tree, invoking the callback for each item
  528. Callback has the form:
  529. def callback(object, path):
  530. """
  531. if path is None:
  532. path = ["."]
  533. if callback(self, path):
  534. for iri, prop, _, _, _, _ in self.__iter_props():
  535. prop.walk(self.__dict__["_obj_data"][iri], callback, path + [f".{iri}"])
  536. def property_keys(self):
  537. for iri, _, _, _, pyname, compact in self.__iter_props():
  538. if iri == "@id":
  539. compact = self.ID_ALIAS
  540. yield pyname, iri, compact
  541. def iter_objects(self, *, recursive=False, visited=None):
  542. """
  543. Iterate of all objects that are a child of this one
  544. """
  545. if visited is None:
  546. visited = set()
  547. for iri, prop, _, _, _, _ in self.__iter_props():
  548. for c in prop.iter_objects(
  549. self.__dict__["_obj_data"][iri], recursive=recursive, visited=visited
  550. ):
  551. yield c
  552. def encode(self, encoder, state):
  553. idname = self.ID_ALIAS or self._OBJ_IRIS["_id"]
  554. if not self._id and self.NODE_KIND == NodeKind.IRI:
  555. raise ValueError(
  556. f"{self.__class__.__name__} ({id(self)}) must have a IRI for property '{idname}'"
  557. )
  558. if state.is_written(self):
  559. encoder.write_iri(state.get_object_id(self))
  560. return
  561. state.add_written(self)
  562. with encoder.write_object(
  563. self,
  564. state.get_object_id(self),
  565. bool(self._id) or state.is_refed(self),
  566. ) as obj_s:
  567. self._encode_properties(obj_s, state)
  568. def _encode_properties(self, encoder, state):
  569. for iri, prop, min_count, max_count, pyname, compact in self.__iter_props():
  570. value = self.__dict__["_obj_data"][iri]
  571. if prop.elide(value):
  572. if min_count:
  573. raise ValueError(
  574. f"Property '{pyname}' in {self.__class__.__name__} ({id(self)}) is required (currently {value!r})"
  575. )
  576. continue
  577. if min_count is not None:
  578. if not prop.check_min_count(value, min_count):
  579. raise ValueError(
  580. f"Property '{pyname}' in {self.__class__.__name__} ({id(self)}) requires a minimum of {min_count} elements"
  581. )
  582. if max_count is not None:
  583. if not prop.check_max_count(value, max_count):
  584. raise ValueError(
  585. f"Property '{pyname}' in {self.__class__.__name__} ({id(self)}) requires a maximum of {max_count} elements"
  586. )
  587. if iri == self._OBJ_IRIS["_id"]:
  588. continue
  589. with encoder.write_property(iri, compact) as prop_s:
  590. prop.encode(prop_s, value, state)
  591. @classmethod
  592. def _make_object(cls, typ):
  593. if typ not in cls.CLASSES:
  594. raise TypeError(f"Unknown type {typ}")
  595. return cls.CLASSES[typ]()
  596. @classmethod
  597. def decode(cls, decoder, *, objectset=None):
  598. typ, obj_d = decoder.read_object()
  599. if typ is None:
  600. raise TypeError("Unable to determine type for object")
  601. obj = cls._make_object(typ)
  602. for key in (obj.ID_ALIAS, obj._OBJ_IRIS["_id"]):
  603. with obj_d.read_property(key) as prop_d:
  604. if prop_d is None:
  605. continue
  606. _id = prop_d.read_iri()
  607. if _id is None:
  608. raise TypeError(f"Object key '{key}' is the wrong type")
  609. obj._id = _id
  610. break
  611. if obj.NODE_KIND == NodeKind.IRI and not obj._id:
  612. raise ValueError("Object is missing required IRI")
  613. if objectset is not None:
  614. if obj._id:
  615. v = objectset.find_by_id(_id)
  616. if v is not None:
  617. return v
  618. obj._decode_properties(obj_d, objectset=objectset)
  619. if objectset is not None:
  620. objectset.add_index(obj)
  621. return obj
  622. def _decode_properties(self, decoder, objectset=None):
  623. for key in decoder.object_keys():
  624. if not self._decode_prop(decoder, key, objectset=objectset):
  625. raise KeyError(f"Unknown property '{key}'")
  626. def _decode_prop(self, decoder, key, objectset=None):
  627. if key in (self._OBJ_IRIS["_id"], self.ID_ALIAS):
  628. return True
  629. for iri, prop, _, _, _, compact in self.__iter_props():
  630. if compact == key:
  631. read_key = compact
  632. elif iri == key:
  633. read_key = iri
  634. else:
  635. continue
  636. with decoder.read_property(read_key) as prop_d:
  637. v = prop.decode(prop_d, objectset=objectset)
  638. prop.validate(v)
  639. self.__dict__["_obj_data"][iri] = v
  640. return True
  641. return False
  642. def link_helper(self, objectset, missing, visited):
  643. if self in visited:
  644. return
  645. visited.add(self)
  646. for iri, prop, _, _, _, _ in self.__iter_props():
  647. self.__dict__["_obj_data"][iri] = prop.link_prop(
  648. self.__dict__["_obj_data"][iri],
  649. objectset,
  650. missing,
  651. visited,
  652. )
  653. def __str__(self):
  654. parts = [
  655. f"{self.__class__.__name__}(",
  656. ]
  657. if self._id:
  658. parts.append(f"@id='{self._id}'")
  659. parts.append(")")
  660. return "".join(parts)
  661. def __hash__(self):
  662. return super().__hash__()
  663. def __eq__(self, other):
  664. return super().__eq__(other)
  665. def __lt__(self, other):
  666. def sort_key(obj):
  667. if isinstance(obj, str):
  668. return (obj, "", "", "")
  669. return (
  670. obj._id or "",
  671. obj.TYPE,
  672. getattr(obj, "name", None) or "",
  673. id(obj),
  674. )
  675. return sort_key(self) < sort_key(other)
  676. class SHACLExtensibleObject(object):
  677. CLOSED = False
  678. def __init__(self, typ=None, **kwargs):
  679. if typ:
  680. self.__dict__["_obj_TYPE"] = (typ, None)
  681. else:
  682. self.__dict__["_obj_TYPE"] = (self._OBJ_TYPE, self._OBJ_COMPACT_TYPE)
  683. super().__init__(**kwargs)
  684. def _is_abstract(self):
  685. # Unknown classes are assumed to not be abstract so that they can be
  686. # deserialized
  687. typ = self.__dict__["_obj_TYPE"][0]
  688. if typ in self.__class__.CLASSES:
  689. return self.__class__.CLASSES[typ].IS_ABSTRACT
  690. return False
  691. @classmethod
  692. def _make_object(cls, typ):
  693. # Check for a known type, and if so, deserialize as that instead
  694. if typ in cls.CLASSES:
  695. return cls.CLASSES[typ]()
  696. obj = cls(typ)
  697. return obj
  698. def _decode_properties(self, decoder, objectset=None):
  699. def decode_value(d):
  700. if not d.is_list():
  701. return d.read_value()
  702. return [decode_value(val_d) for val_d in d.read_list()]
  703. if self.CLOSED:
  704. super()._decode_properties(decoder, objectset=objectset)
  705. return
  706. for key in decoder.object_keys():
  707. if self._decode_prop(decoder, key, objectset=objectset):
  708. continue
  709. if not is_IRI(key):
  710. raise KeyError(
  711. f"Extensible object properties must be IRIs. Got '{key}'"
  712. )
  713. with decoder.read_property(key) as prop_d:
  714. self.__dict__["_obj_data"][key] = decode_value(prop_d)
  715. def _encode_properties(self, encoder, state):
  716. def encode_value(encoder, v):
  717. if isinstance(v, bool):
  718. encoder.write_bool(v)
  719. elif isinstance(v, str):
  720. encoder.write_string(v)
  721. elif isinstance(v, int):
  722. encoder.write_integer(v)
  723. elif isinstance(v, float):
  724. encoder.write_float(v)
  725. elif isinstance(v, list):
  726. with encoder.write_list() as list_s:
  727. for i in v:
  728. with list_s.write_list_item() as item_s:
  729. encode_value(item_s, i)
  730. else:
  731. raise TypeError(
  732. f"Unsupported serialized type {type(v)} with value '{v}'"
  733. )
  734. super()._encode_properties(encoder, state)
  735. if self.CLOSED:
  736. return
  737. for iri, value in self.__dict__["_obj_data"].items():
  738. if iri in self._OBJ_PROPERTIES:
  739. continue
  740. with encoder.write_property(iri) as prop_s:
  741. encode_value(prop_s, value)
  742. def __setitem__(self, iri, value):
  743. try:
  744. super().__setitem__(iri, value)
  745. except KeyError:
  746. if self.CLOSED:
  747. raise
  748. if not is_IRI(iri):
  749. raise KeyError(f"Key '{iri}' must be an IRI")
  750. self.__dict__["_obj_data"][iri] = value
  751. def __delitem__(self, iri):
  752. try:
  753. super().__delitem__(iri)
  754. except KeyError:
  755. if self.CLOSED:
  756. raise
  757. if not is_IRI(iri):
  758. raise KeyError(f"Key '{iri}' must be an IRI")
  759. del self.__dict__["_obj_data"][iri]
  760. def __getattr__(self, name):
  761. if name == "TYPE":
  762. return self.__dict__["_obj_TYPE"][0]
  763. if name == "COMPACT_TYPE":
  764. return self.__dict__["_obj_TYPE"][1]
  765. return super().__getattr__(name)
  766. def property_keys(self):
  767. iris = set()
  768. for pyname, iri, compact in super().property_keys():
  769. iris.add(iri)
  770. yield pyname, iri, compact
  771. if self.CLOSED:
  772. return
  773. for iri in self.__dict__["_obj_data"].keys():
  774. if iri not in iris:
  775. yield None, iri, None
  776. class SHACLObjectSet(object):
  777. def __init__(self, objects=[], *, link=False):
  778. self.objects = set()
  779. self.missing_ids = set()
  780. for o in objects:
  781. self.objects.add(o)
  782. self.create_index()
  783. if link:
  784. self._link()
  785. def create_index(self):
  786. """
  787. (re)Create object index
  788. Creates or recreates the indices for the object set to enable fast
  789. lookup. All objects and their children are walked and indexed
  790. """
  791. self.obj_by_id = {}
  792. self.obj_by_type = {}
  793. for o in self.foreach():
  794. self.add_index(o)
  795. def add_index(self, obj):
  796. """
  797. Add object to index
  798. Adds the object to all appropriate indices
  799. """
  800. def reg_type(typ, compact, o, exact):
  801. self.obj_by_type.setdefault(typ, set()).add((exact, o))
  802. if compact:
  803. self.obj_by_type.setdefault(compact, set()).add((exact, o))
  804. if not isinstance(obj, SHACLObject):
  805. raise TypeError("Object is not of type SHACLObject")
  806. for typ in SHACLObject.CLASSES.values():
  807. if isinstance(obj, typ):
  808. reg_type(
  809. typ._OBJ_TYPE, typ._OBJ_COMPACT_TYPE, obj, obj.__class__ is typ
  810. )
  811. # This covers custom extensions
  812. reg_type(obj.TYPE, obj.COMPACT_TYPE, obj, True)
  813. if not obj._id:
  814. return
  815. self.missing_ids.discard(obj._id)
  816. if obj._id in self.obj_by_id:
  817. return
  818. self.obj_by_id[obj._id] = obj
  819. def add(self, obj):
  820. """
  821. Add object to object set
  822. Adds a SHACLObject to the object set and index it.
  823. NOTE: Child objects of the attached object are not indexes
  824. """
  825. if not isinstance(obj, SHACLObject):
  826. raise TypeError("Object is not of type SHACLObject")
  827. if obj not in self.objects:
  828. self.objects.add(obj)
  829. self.add_index(obj)
  830. return obj
  831. def update(self, *others):
  832. """
  833. Update object set adding all objects in each other iterable
  834. """
  835. for o in others:
  836. for obj in o:
  837. self.add(obj)
  838. def __contains__(self, item):
  839. """
  840. Returns True if the item is in the object set
  841. """
  842. return item in self.objects
  843. def link(self):
  844. """
  845. Link object set
  846. Links the object in the object set by replacing string object
  847. references with references to the objects themselves. e.g.
  848. a property that references object "https://foo/bar" by a string
  849. reference will be replaced with an actual reference to the object in
  850. the object set with the same ID if it exists in the object set
  851. If multiple objects with the same ID are found, the duplicates are
  852. eliminated
  853. """
  854. self.create_index()
  855. return self._link()
  856. def _link(self):
  857. global NAMED_INDIVIDUALS
  858. self.missing_ids = set()
  859. visited = set()
  860. new_objects = set()
  861. for o in self.objects:
  862. if o._id:
  863. o = self.find_by_id(o._id, o)
  864. o.link_helper(self, self.missing_ids, visited)
  865. new_objects.add(o)
  866. self.objects = new_objects
  867. # Remove blank nodes
  868. obj_by_id = {}
  869. for _id, obj in self.obj_by_id.items():
  870. if _id.startswith("_:"):
  871. del obj._id
  872. else:
  873. obj_by_id[_id] = obj
  874. self.obj_by_id = obj_by_id
  875. # Named individuals aren't considered missing
  876. self.missing_ids -= NAMED_INDIVIDUALS
  877. return self.missing_ids
  878. def find_by_id(self, _id, default=None):
  879. """
  880. Find object by ID
  881. Returns objects that match the specified ID, or default if there is no
  882. object with the specified ID
  883. """
  884. if _id not in self.obj_by_id:
  885. return default
  886. return self.obj_by_id[_id]
  887. def foreach(self):
  888. """
  889. Iterate over every object in the object set, and all child objects
  890. """
  891. visited = set()
  892. for o in self.objects:
  893. if o not in visited:
  894. yield o
  895. visited.add(o)
  896. for child in o.iter_objects(recursive=True, visited=visited):
  897. yield child
  898. def foreach_type(self, typ, *, match_subclass=True):
  899. """
  900. Iterate over each object of a specified type (or subclass there of)
  901. If match_subclass is True, and class derived from typ will also match
  902. (similar to isinstance()). If False, only exact matches will be
  903. returned
  904. """
  905. if not isinstance(typ, str):
  906. if not issubclass(typ, SHACLObject):
  907. raise TypeError(f"Type must be derived from SHACLObject, got {typ}")
  908. typ = typ._OBJ_TYPE
  909. if typ not in self.obj_by_type:
  910. return
  911. for exact, o in self.obj_by_type[typ]:
  912. if match_subclass or exact:
  913. yield o
  914. def merge(self, *objectsets):
  915. """
  916. Merge object sets
  917. Returns a new object set that is the combination of this object set and
  918. all provided arguments
  919. """
  920. new_objects = set()
  921. new_objects |= self.objects
  922. for d in objectsets:
  923. new_objects |= d.objects
  924. return SHACLObjectSet(new_objects, link=True)
  925. def encode(self, encoder, force_list=False, *, key=None):
  926. """
  927. Serialize a list of objects to a serialization encoder
  928. If force_list is true, a list will always be written using the encoder.
  929. """
  930. ref_counts = {}
  931. state = EncodeState()
  932. def walk_callback(value, path):
  933. nonlocal state
  934. nonlocal ref_counts
  935. if not isinstance(value, SHACLObject):
  936. return True
  937. # Remove blank node ID for re-assignment
  938. if value._id and value._id.startswith("_:"):
  939. del value._id
  940. if value._id:
  941. state.add_refed(value)
  942. # If the object is referenced more than once, add it to the set of
  943. # referenced objects
  944. ref_counts.setdefault(value, 0)
  945. ref_counts[value] += 1
  946. if ref_counts[value] > 1:
  947. state.add_refed(value)
  948. return False
  949. return True
  950. for o in self.objects:
  951. if o._id:
  952. state.add_refed(o)
  953. o.walk(walk_callback)
  954. use_list = force_list or len(self.objects) > 1
  955. if use_list:
  956. # If we are making a list add all the objects referred to by reference
  957. # to the list
  958. objects = list(self.objects | state.ref_objects)
  959. else:
  960. objects = list(self.objects)
  961. objects.sort(key=key)
  962. if use_list:
  963. # Ensure top level objects are only written in the top level graph
  964. # node, and referenced by ID everywhere else. This is done by setting
  965. # the flag that indicates this object has been written for all the top
  966. # level objects, then clearing it right before serializing the object.
  967. #
  968. # In this way, if an object is referenced before it is supposed to be
  969. # serialized into the @graph, it will serialize as a string instead of
  970. # the actual object
  971. for o in objects:
  972. state.written_objects.add(o)
  973. with encoder.write_list() as list_s:
  974. for o in objects:
  975. # Allow this specific object to be written now
  976. state.written_objects.remove(o)
  977. with list_s.write_list_item() as item_s:
  978. o.encode(item_s, state)
  979. elif objects:
  980. objects[0].encode(encoder, state)
  981. def decode(self, decoder):
  982. self.create_index()
  983. for obj_d in decoder.read_list():
  984. o = SHACLObject.decode(obj_d, objectset=self)
  985. self.objects.add(o)
  986. self._link()
  987. class EncodeState(object):
  988. def __init__(self):
  989. self.ref_objects = set()
  990. self.written_objects = set()
  991. self.blank_objects = {}
  992. def get_object_id(self, o):
  993. if o._id:
  994. return o._id
  995. if o not in self.blank_objects:
  996. _id = f"_:{o.__class__.__name__}{len(self.blank_objects)}"
  997. self.blank_objects[o] = _id
  998. return self.blank_objects[o]
  999. def is_refed(self, o):
  1000. return o in self.ref_objects
  1001. def add_refed(self, o):
  1002. self.ref_objects.add(o)
  1003. def is_written(self, o):
  1004. return o in self.written_objects
  1005. def add_written(self, o):
  1006. self.written_objects.add(o)
  1007. class Decoder(ABC):
  1008. @abstractmethod
  1009. def read_value(self):
  1010. """
  1011. Consume next item
  1012. Consumes the next item of any type
  1013. """
  1014. pass
  1015. @abstractmethod
  1016. def read_string(self):
  1017. """
  1018. Consume the next item as a string.
  1019. Returns the string value of the next item, or `None` if the next item
  1020. is not a string
  1021. """
  1022. pass
  1023. @abstractmethod
  1024. def read_datetime(self):
  1025. """
  1026. Consumes the next item as a date & time string
  1027. Returns the string value of the next item, if it is a ISO datetime, or
  1028. `None` if the next item is not a ISO datetime string.
  1029. Note that validation of the string is done by the caller, so a minimal
  1030. implementation can just check if the next item is a string without
  1031. worrying about the format
  1032. """
  1033. pass
  1034. @abstractmethod
  1035. def read_integer(self):
  1036. """
  1037. Consumes the next item as an integer
  1038. Returns the integer value of the next item, or `None` if the next item
  1039. is not an integer
  1040. """
  1041. pass
  1042. @abstractmethod
  1043. def read_iri(self):
  1044. """
  1045. Consumes the next item as an IRI string
  1046. Returns the string value of the next item an IRI, or `None` if the next
  1047. item is not an IRI.
  1048. The returned string should be either a fully-qualified IRI, or a blank
  1049. node ID
  1050. """
  1051. pass
  1052. @abstractmethod
  1053. def read_enum(self, e):
  1054. """
  1055. Consumes the next item as an Enum value string
  1056. Returns the fully qualified IRI of the next enum item, or `None` if the
  1057. next item is not an enum value.
  1058. The callee is responsible for validating that the returned IRI is
  1059. actually a member of the specified Enum, so the `Decoder` does not need
  1060. to check that, but can if it wishes
  1061. """
  1062. pass
  1063. @abstractmethod
  1064. def read_bool(self):
  1065. """
  1066. Consume the next item as a boolean value
  1067. Returns the boolean value of the next item, or `None` if the next item
  1068. is not a boolean
  1069. """
  1070. pass
  1071. @abstractmethod
  1072. def read_float(self):
  1073. """
  1074. Consume the next item as a float value
  1075. Returns the float value of the next item, or `None` if the next item is
  1076. not a float
  1077. """
  1078. pass
  1079. @abstractmethod
  1080. def read_list(self):
  1081. """
  1082. Consume the next item as a list generator
  1083. This should generate a `Decoder` object for each item in the list. The
  1084. generated `Decoder` can be used to read the corresponding item from the
  1085. list
  1086. """
  1087. pass
  1088. @abstractmethod
  1089. def is_list(self):
  1090. """
  1091. Checks if the next item is a list
  1092. Returns True if the next item is a list, or False if it is a scalar
  1093. """
  1094. pass
  1095. @abstractmethod
  1096. def read_object(self):
  1097. """
  1098. Consume next item as an object
  1099. A context manager that "enters" the next item as a object and yields a
  1100. `Decoder` that can read properties from it. If the next item is not an
  1101. object, yields `None`
  1102. Properties will be read out of the object using `read_property` and
  1103. `read_object_id`
  1104. """
  1105. pass
  1106. @abstractmethod
  1107. @contextmanager
  1108. def read_property(self, key):
  1109. """
  1110. Read property from object
  1111. A context manager that yields a `Decoder` that can be used to read the
  1112. value of the property with the given key in current object, or `None`
  1113. if the property does not exist in the current object.
  1114. """
  1115. pass
  1116. @abstractmethod
  1117. def object_keys(self):
  1118. """
  1119. Read property keys from an object
  1120. Iterates over all the serialized keys for the current object
  1121. """
  1122. pass
  1123. @abstractmethod
  1124. def read_object_id(self, alias=None):
  1125. """
  1126. Read current object ID property
  1127. Returns the ID of the current object if one is defined, or `None` if
  1128. the current object has no ID.
  1129. The ID must be a fully qualified IRI or a blank node
  1130. If `alias` is provided, is is a hint as to another name by which the ID
  1131. might be found, if the `Decoder` supports aliases for an ID
  1132. """
  1133. pass
  1134. class JSONLDDecoder(Decoder):
  1135. def __init__(self, data, root=False):
  1136. self.data = data
  1137. self.root = root
  1138. def read_value(self):
  1139. if isinstance(self.data, str):
  1140. try:
  1141. return float(self.data)
  1142. except ValueError:
  1143. pass
  1144. return self.data
  1145. def read_string(self):
  1146. if isinstance(self.data, str):
  1147. return self.data
  1148. return None
  1149. def read_datetime(self):
  1150. return self.read_string()
  1151. def read_integer(self):
  1152. if isinstance(self.data, int):
  1153. return self.data
  1154. return None
  1155. def read_bool(self):
  1156. if isinstance(self.data, bool):
  1157. return self.data
  1158. return None
  1159. def read_float(self):
  1160. if isinstance(self.data, (int, float, str)):
  1161. return float(self.data)
  1162. return None
  1163. def read_iri(self):
  1164. if isinstance(self.data, str):
  1165. return self.data
  1166. return None
  1167. def read_enum(self, e):
  1168. if isinstance(self.data, str):
  1169. return self.data
  1170. return None
  1171. def read_list(self):
  1172. if self.is_list():
  1173. for v in self.data:
  1174. yield self.__class__(v)
  1175. else:
  1176. yield self
  1177. def is_list(self):
  1178. return isinstance(self.data, (list, tuple, set))
  1179. def __get_value(self, *keys):
  1180. for k in keys:
  1181. if k and k in self.data:
  1182. return self.data[k]
  1183. return None
  1184. @contextmanager
  1185. def read_property(self, key):
  1186. v = self.__get_value(key)
  1187. if v is not None:
  1188. yield self.__class__(v)
  1189. else:
  1190. yield None
  1191. def object_keys(self):
  1192. for key in self.data.keys():
  1193. if key in ("@type", "type"):
  1194. continue
  1195. if self.root and key == "@context":
  1196. continue
  1197. yield key
  1198. def read_object(self):
  1199. typ = self.__get_value("@type", "type")
  1200. if typ is not None:
  1201. return typ, self
  1202. return None, self
  1203. def read_object_id(self, alias=None):
  1204. return self.__get_value(alias, "@id")
  1205. class JSONLDDeserializer(object):
  1206. def deserialize_data(self, data, objectset: SHACLObjectSet):
  1207. if "@graph" in data:
  1208. h = JSONLDDecoder(data["@graph"], True)
  1209. else:
  1210. h = JSONLDDecoder(data, True)
  1211. objectset.decode(h)
  1212. def read(self, f, objectset: SHACLObjectSet):
  1213. data = json.load(f)
  1214. self.deserialize_data(data, objectset)
  1215. class Encoder(ABC):
  1216. @abstractmethod
  1217. def write_string(self, v):
  1218. """
  1219. Write a string value
  1220. Encodes the value as a string in the output
  1221. """
  1222. pass
  1223. @abstractmethod
  1224. def write_datetime(self, v):
  1225. """
  1226. Write a date & time string
  1227. Encodes the value as an ISO datetime string
  1228. Note: The provided string is already correctly encoded as an ISO datetime
  1229. """
  1230. pass
  1231. @abstractmethod
  1232. def write_integer(self, v):
  1233. """
  1234. Write an integer value
  1235. Encodes the value as an integer in the output
  1236. """
  1237. pass
  1238. @abstractmethod
  1239. def write_iri(self, v, compact=None):
  1240. """
  1241. Write IRI
  1242. Encodes the string as an IRI. Note that the string will be either a
  1243. fully qualified IRI or a blank node ID. If `compact` is provided and
  1244. the serialization supports compacted IRIs, it should be preferred to
  1245. the full IRI
  1246. """
  1247. pass
  1248. @abstractmethod
  1249. def write_enum(self, v, e, compact=None):
  1250. """
  1251. Write enum value IRI
  1252. Encodes the string enum value IRI. Note that the string will be a fully
  1253. qualified IRI. If `compact` is provided and the serialization supports
  1254. compacted IRIs, it should be preferred to the full IRI.
  1255. """
  1256. pass
  1257. @abstractmethod
  1258. def write_bool(self, v):
  1259. """
  1260. Write boolean
  1261. Encodes the value as a boolean in the output
  1262. """
  1263. pass
  1264. @abstractmethod
  1265. def write_float(self, v):
  1266. """
  1267. Write float
  1268. Encodes the value as a floating point number in the output
  1269. """
  1270. pass
  1271. @abstractmethod
  1272. @contextmanager
  1273. def write_object(self, o, _id, needs_id):
  1274. """
  1275. Write object
  1276. A context manager that yields an `Encoder` that can be used to encode
  1277. the given object properties.
  1278. The provided ID will always be a valid ID (even if o._id is `None`), in
  1279. case the `Encoder` _must_ have an ID. `needs_id` is a hint to indicate
  1280. to the `Encoder` if an ID must be written or not (if that is even an
  1281. option). If it is `True`, the `Encoder` must encode an ID for the
  1282. object. If `False`, the encoder is not required to encode an ID and may
  1283. omit it.
  1284. The ID will be either a fully qualified IRI, or a blank node IRI.
  1285. Properties will be written the object using `write_property`
  1286. """
  1287. pass
  1288. @abstractmethod
  1289. @contextmanager
  1290. def write_property(self, iri, compact=None):
  1291. """
  1292. Write object property
  1293. A context manager that yields an `Encoder` that can be used to encode
  1294. the value for the property with the given IRI in the current object
  1295. Note that the IRI will be fully qualified. If `compact` is provided and
  1296. the serialization supports compacted IRIs, it should be preferred to
  1297. the full IRI.
  1298. """
  1299. pass
  1300. @abstractmethod
  1301. @contextmanager
  1302. def write_list(self):
  1303. """
  1304. Write list
  1305. A context manager that yields an `Encoder` that can be used to encode a
  1306. list.
  1307. Each item of the list will be added using `write_list_item`
  1308. """
  1309. pass
  1310. @abstractmethod
  1311. @contextmanager
  1312. def write_list_item(self):
  1313. """
  1314. Write list item
  1315. A context manager that yields an `Encoder` that can be used to encode
  1316. the value for a list item
  1317. """
  1318. pass
  1319. class JSONLDEncoder(Encoder):
  1320. def __init__(self, data=None):
  1321. self.data = data
  1322. def write_string(self, v):
  1323. self.data = v
  1324. def write_datetime(self, v):
  1325. self.data = v
  1326. def write_integer(self, v):
  1327. self.data = v
  1328. def write_iri(self, v, compact=None):
  1329. self.write_string(compact or v)
  1330. def write_enum(self, v, e, compact=None):
  1331. self.write_string(compact or v)
  1332. def write_bool(self, v):
  1333. self.data = v
  1334. def write_float(self, v):
  1335. self.data = str(v)
  1336. @contextmanager
  1337. def write_property(self, iri, compact=None):
  1338. s = self.__class__(None)
  1339. yield s
  1340. if s.data is not None:
  1341. self.data[compact or iri] = s.data
  1342. @contextmanager
  1343. def write_object(self, o, _id, needs_id):
  1344. self.data = {
  1345. "type": o.COMPACT_TYPE or o.TYPE,
  1346. }
  1347. if needs_id:
  1348. self.data[o.ID_ALIAS or "@id"] = _id
  1349. yield self
  1350. @contextmanager
  1351. def write_list(self):
  1352. self.data = []
  1353. yield self
  1354. if not self.data:
  1355. self.data = None
  1356. @contextmanager
  1357. def write_list_item(self):
  1358. s = self.__class__(None)
  1359. yield s
  1360. if s.data is not None:
  1361. self.data.append(s.data)
  1362. class JSONLDSerializer(object):
  1363. def __init__(self, **args):
  1364. self.args = args
  1365. def serialize_data(
  1366. self,
  1367. objectset: SHACLObjectSet,
  1368. force_at_graph=False,
  1369. ):
  1370. h = JSONLDEncoder()
  1371. objectset.encode(h, force_at_graph)
  1372. data = {}
  1373. if len(CONTEXT_URLS) == 1:
  1374. data["@context"] = CONTEXT_URLS[0]
  1375. elif CONTEXT_URLS:
  1376. data["@context"] = CONTEXT_URLS
  1377. if isinstance(h.data, list):
  1378. data["@graph"] = h.data
  1379. else:
  1380. for k, v in h.data.items():
  1381. data[k] = v
  1382. return data
  1383. def write(
  1384. self,
  1385. objectset: SHACLObjectSet,
  1386. f,
  1387. force_at_graph=False,
  1388. **kwargs,
  1389. ):
  1390. """
  1391. Write a SHACLObjectSet to a JSON LD file
  1392. If force_at_graph is True, a @graph node will always be written
  1393. """
  1394. data = self.serialize_data(objectset, force_at_graph)
  1395. args = {**self.args, **kwargs}
  1396. sha1 = hashlib.sha1()
  1397. for chunk in json.JSONEncoder(**args).iterencode(data):
  1398. chunk = chunk.encode("utf-8")
  1399. f.write(chunk)
  1400. sha1.update(chunk)
  1401. return sha1.hexdigest()
  1402. class JSONLDInlineEncoder(Encoder):
  1403. def __init__(self, f, sha1):
  1404. self.f = f
  1405. self.comma = False
  1406. self.sha1 = sha1
  1407. def write(self, s):
  1408. s = s.encode("utf-8")
  1409. self.f.write(s)
  1410. self.sha1.update(s)
  1411. def _write_comma(self):
  1412. if self.comma:
  1413. self.write(",")
  1414. self.comma = False
  1415. def write_string(self, v):
  1416. self.write(json.dumps(v))
  1417. def write_datetime(self, v):
  1418. self.write_string(v)
  1419. def write_integer(self, v):
  1420. self.write(f"{v}")
  1421. def write_iri(self, v, compact=None):
  1422. self.write_string(compact or v)
  1423. def write_enum(self, v, e, compact=None):
  1424. self.write_iri(v, compact)
  1425. def write_bool(self, v):
  1426. if v:
  1427. self.write("true")
  1428. else:
  1429. self.write("false")
  1430. def write_float(self, v):
  1431. self.write(json.dumps(str(v)))
  1432. @contextmanager
  1433. def write_property(self, iri, compact=None):
  1434. self._write_comma()
  1435. self.write_string(compact or iri)
  1436. self.write(":")
  1437. yield self
  1438. self.comma = True
  1439. @contextmanager
  1440. def write_object(self, o, _id, needs_id):
  1441. self._write_comma()
  1442. self.write("{")
  1443. self.write_string("type")
  1444. self.write(":")
  1445. self.write_string(o.COMPACT_TYPE or o.TYPE)
  1446. self.comma = True
  1447. if needs_id:
  1448. self._write_comma()
  1449. self.write_string(o.ID_ALIAS or "@id")
  1450. self.write(":")
  1451. self.write_string(_id)
  1452. self.comma = True
  1453. self.comma = True
  1454. yield self
  1455. self.write("}")
  1456. self.comma = True
  1457. @contextmanager
  1458. def write_list(self):
  1459. self._write_comma()
  1460. self.write("[")
  1461. yield self.__class__(self.f, self.sha1)
  1462. self.write("]")
  1463. self.comma = True
  1464. @contextmanager
  1465. def write_list_item(self):
  1466. self._write_comma()
  1467. yield self.__class__(self.f, self.sha1)
  1468. self.comma = True
  1469. class JSONLDInlineSerializer(object):
  1470. def write(
  1471. self,
  1472. objectset: SHACLObjectSet,
  1473. f,
  1474. force_at_graph=False,
  1475. ):
  1476. """
  1477. Write a SHACLObjectSet to a JSON LD file
  1478. Note: force_at_graph is included for compatibility, but ignored. This
  1479. serializer always writes out a graph
  1480. """
  1481. sha1 = hashlib.sha1()
  1482. h = JSONLDInlineEncoder(f, sha1)
  1483. h.write('{"@context":')
  1484. if len(CONTEXT_URLS) == 1:
  1485. h.write(f'"{CONTEXT_URLS[0]}"')
  1486. elif CONTEXT_URLS:
  1487. h.write('["')
  1488. h.write('","'.join(CONTEXT_URLS))
  1489. h.write('"]')
  1490. h.write(",")
  1491. h.write('"@graph":')
  1492. objectset.encode(h, True)
  1493. h.write("}")
  1494. return sha1.hexdigest()
  1495. def print_tree(objects, all_fields=False):
  1496. """
  1497. Print object tree
  1498. """
  1499. seen = set()
  1500. def callback(value, path):
  1501. nonlocal seen
  1502. s = (" " * (len(path) - 1)) + f"{path[-1]}"
  1503. if isinstance(value, SHACLObject):
  1504. s += f" {value} ({id(value)})"
  1505. is_empty = False
  1506. elif isinstance(value, ListProxy):
  1507. is_empty = len(value) == 0
  1508. if is_empty:
  1509. s += " []"
  1510. else:
  1511. s += f" {value!r}"
  1512. is_empty = value is None
  1513. if all_fields or not is_empty:
  1514. print(s)
  1515. if isinstance(value, SHACLObject):
  1516. if value in seen:
  1517. return False
  1518. seen.add(value)
  1519. return True
  1520. return True
  1521. for o in objects:
  1522. o.walk(callback)
  1523. # fmt: off
  1524. """Format Guard"""
  1525. CONTEXT_URLS = [
  1526. "https://spdx.org/rdf/3.0.1/spdx-context.jsonld",
  1527. ]
  1528. # CLASSES
  1529. # A class for describing the energy consumption incurred by an AI model in
  1530. # different stages of its lifecycle.
  1531. @register("https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumption", compact_type="ai_EnergyConsumption", abstract=False)
  1532. class ai_EnergyConsumption(SHACLObject):
  1533. NODE_KIND = NodeKind.BlankNodeOrIRI
  1534. NAMED_INDIVIDUALS = {
  1535. }
  1536. @classmethod
  1537. def _register_props(cls):
  1538. super()._register_props()
  1539. # Specifies the amount of energy consumed when finetuning the AI model that is
  1540. # being used in the AI system.
  1541. cls._add_property(
  1542. "ai_finetuningEnergyConsumption",
  1543. ListProp(ObjectProp(ai_EnergyConsumptionDescription, False)),
  1544. iri="https://spdx.org/rdf/3.0.1/terms/AI/finetuningEnergyConsumption",
  1545. compact="ai_finetuningEnergyConsumption",
  1546. )
  1547. # Specifies the amount of energy consumed during inference time by an AI model
  1548. # that is being used in the AI system.
  1549. cls._add_property(
  1550. "ai_inferenceEnergyConsumption",
  1551. ListProp(ObjectProp(ai_EnergyConsumptionDescription, False)),
  1552. iri="https://spdx.org/rdf/3.0.1/terms/AI/inferenceEnergyConsumption",
  1553. compact="ai_inferenceEnergyConsumption",
  1554. )
  1555. # Specifies the amount of energy consumed when training the AI model that is
  1556. # being used in the AI system.
  1557. cls._add_property(
  1558. "ai_trainingEnergyConsumption",
  1559. ListProp(ObjectProp(ai_EnergyConsumptionDescription, False)),
  1560. iri="https://spdx.org/rdf/3.0.1/terms/AI/trainingEnergyConsumption",
  1561. compact="ai_trainingEnergyConsumption",
  1562. )
  1563. # The class that helps note down the quantity of energy consumption and the unit
  1564. # used for measurement.
  1565. @register("https://spdx.org/rdf/3.0.1/terms/AI/EnergyConsumptionDescription", compact_type="ai_EnergyConsumptionDescription", abstract=False)
  1566. class ai_EnergyConsumptionDescription(SHACLObject):
  1567. NODE_KIND = NodeKind.BlankNodeOrIRI
  1568. NAMED_INDIVIDUALS = {
  1569. }
  1570. @classmethod
  1571. def _register_props(cls):
  1572. super()._register_props()
  1573. # Represents the energy quantity.
  1574. cls._add_property(
  1575. "ai_energyQuantity",
  1576. FloatProp(),
  1577. iri="https://spdx.org/rdf/3.0.1/terms/AI/energyQuantity",
  1578. min_count=1,
  1579. compact="ai_energyQuantity",
  1580. )
  1581. # Specifies the unit in which energy is measured.
  1582. cls._add_property(
  1583. "ai_energyUnit",
  1584. EnumProp([
  1585. ("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/kilowattHour", "kilowattHour"),
  1586. ("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/megajoule", "megajoule"),
  1587. ("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/other", "other"),
  1588. ]),
  1589. iri="https://spdx.org/rdf/3.0.1/terms/AI/energyUnit",
  1590. min_count=1,
  1591. compact="ai_energyUnit",
  1592. )
  1593. # Specifies the unit of energy consumption.
  1594. @register("https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType", compact_type="ai_EnergyUnitType", abstract=False)
  1595. class ai_EnergyUnitType(SHACLObject):
  1596. NODE_KIND = NodeKind.BlankNodeOrIRI
  1597. NAMED_INDIVIDUALS = {
  1598. "kilowattHour": "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/kilowattHour",
  1599. "megajoule": "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/megajoule",
  1600. "other": "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/other",
  1601. }
  1602. # Kilowatt-hour.
  1603. kilowattHour = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/kilowattHour"
  1604. # Megajoule.
  1605. megajoule = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/megajoule"
  1606. # Any other units of energy measurement.
  1607. other = "https://spdx.org/rdf/3.0.1/terms/AI/EnergyUnitType/other"
  1608. # Specifies the safety risk level.
  1609. @register("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType", compact_type="ai_SafetyRiskAssessmentType", abstract=False)
  1610. class ai_SafetyRiskAssessmentType(SHACLObject):
  1611. NODE_KIND = NodeKind.BlankNodeOrIRI
  1612. NAMED_INDIVIDUALS = {
  1613. "high": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/high",
  1614. "low": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/low",
  1615. "medium": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/medium",
  1616. "serious": "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/serious",
  1617. }
  1618. # The second-highest level of risk posed by an AI system.
  1619. high = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/high"
  1620. # Low/no risk is posed by an AI system.
  1621. low = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/low"
  1622. # The third-highest level of risk posed by an AI system.
  1623. medium = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/medium"
  1624. # The highest level of risk posed by an AI system.
  1625. serious = "https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/serious"
  1626. # Specifies the type of an annotation.
  1627. @register("https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType", compact_type="AnnotationType", abstract=False)
  1628. class AnnotationType(SHACLObject):
  1629. NODE_KIND = NodeKind.BlankNodeOrIRI
  1630. NAMED_INDIVIDUALS = {
  1631. "other": "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/other",
  1632. "review": "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/review",
  1633. }
  1634. # Used to store extra information about an Element which is not part of a review (e.g. extra information provided during the creation of the Element).
  1635. other = "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/other"
  1636. # Used when someone reviews the Element.
  1637. review = "https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/review"
  1638. # Provides information about the creation of the Element.
  1639. @register("https://spdx.org/rdf/3.0.1/terms/Core/CreationInfo", compact_type="CreationInfo", abstract=False)
  1640. class CreationInfo(SHACLObject):
  1641. NODE_KIND = NodeKind.BlankNodeOrIRI
  1642. NAMED_INDIVIDUALS = {
  1643. }
  1644. @classmethod
  1645. def _register_props(cls):
  1646. super()._register_props()
  1647. # Provide consumers with comments by the creator of the Element about the
  1648. # Element.
  1649. cls._add_property(
  1650. "comment",
  1651. StringProp(),
  1652. iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
  1653. compact="comment",
  1654. )
  1655. # Identifies when the Element was originally created.
  1656. cls._add_property(
  1657. "created",
  1658. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  1659. iri="https://spdx.org/rdf/3.0.1/terms/Core/created",
  1660. min_count=1,
  1661. compact="created",
  1662. )
  1663. # Identifies who or what created the Element.
  1664. cls._add_property(
  1665. "createdBy",
  1666. ListProp(ObjectProp(Agent, False, context=[
  1667. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  1668. ],)),
  1669. iri="https://spdx.org/rdf/3.0.1/terms/Core/createdBy",
  1670. min_count=1,
  1671. compact="createdBy",
  1672. )
  1673. # Identifies the tooling that was used during the creation of the Element.
  1674. cls._add_property(
  1675. "createdUsing",
  1676. ListProp(ObjectProp(Tool, False)),
  1677. iri="https://spdx.org/rdf/3.0.1/terms/Core/createdUsing",
  1678. compact="createdUsing",
  1679. )
  1680. # Provides a reference number that can be used to understand how to parse and
  1681. # interpret an Element.
  1682. cls._add_property(
  1683. "specVersion",
  1684. StringProp(pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",),
  1685. iri="https://spdx.org/rdf/3.0.1/terms/Core/specVersion",
  1686. min_count=1,
  1687. compact="specVersion",
  1688. )
  1689. # A key with an associated value.
  1690. @register("https://spdx.org/rdf/3.0.1/terms/Core/DictionaryEntry", compact_type="DictionaryEntry", abstract=False)
  1691. class DictionaryEntry(SHACLObject):
  1692. NODE_KIND = NodeKind.BlankNodeOrIRI
  1693. NAMED_INDIVIDUALS = {
  1694. }
  1695. @classmethod
  1696. def _register_props(cls):
  1697. super()._register_props()
  1698. # A key used in a generic key-value pair.
  1699. cls._add_property(
  1700. "key",
  1701. StringProp(),
  1702. iri="https://spdx.org/rdf/3.0.1/terms/Core/key",
  1703. min_count=1,
  1704. compact="key",
  1705. )
  1706. # A value used in a generic key-value pair.
  1707. cls._add_property(
  1708. "value",
  1709. StringProp(),
  1710. iri="https://spdx.org/rdf/3.0.1/terms/Core/value",
  1711. compact="value",
  1712. )
  1713. # Base domain class from which all other SPDX-3.0 domain classes derive.
  1714. @register("https://spdx.org/rdf/3.0.1/terms/Core/Element", compact_type="Element", abstract=True)
  1715. class Element(SHACLObject):
  1716. NODE_KIND = NodeKind.IRI
  1717. ID_ALIAS = "spdxId"
  1718. NAMED_INDIVIDUALS = {
  1719. }
  1720. @classmethod
  1721. def _register_props(cls):
  1722. super()._register_props()
  1723. # Provide consumers with comments by the creator of the Element about the
  1724. # Element.
  1725. cls._add_property(
  1726. "comment",
  1727. StringProp(),
  1728. iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
  1729. compact="comment",
  1730. )
  1731. # Provides information about the creation of the Element.
  1732. cls._add_property(
  1733. "creationInfo",
  1734. ObjectProp(CreationInfo, True),
  1735. iri="https://spdx.org/rdf/3.0.1/terms/Core/creationInfo",
  1736. min_count=1,
  1737. compact="creationInfo",
  1738. )
  1739. # Provides a detailed description of the Element.
  1740. cls._add_property(
  1741. "description",
  1742. StringProp(),
  1743. iri="https://spdx.org/rdf/3.0.1/terms/Core/description",
  1744. compact="description",
  1745. )
  1746. # Specifies an Extension characterization of some aspect of an Element.
  1747. cls._add_property(
  1748. "extension",
  1749. ListProp(ObjectProp(extension_Extension, False)),
  1750. iri="https://spdx.org/rdf/3.0.1/terms/Core/extension",
  1751. compact="extension",
  1752. )
  1753. # Provides a reference to a resource outside the scope of SPDX-3.0 content
  1754. # that uniquely identifies an Element.
  1755. cls._add_property(
  1756. "externalIdentifier",
  1757. ListProp(ObjectProp(ExternalIdentifier, False)),
  1758. iri="https://spdx.org/rdf/3.0.1/terms/Core/externalIdentifier",
  1759. compact="externalIdentifier",
  1760. )
  1761. # Points to a resource outside the scope of the SPDX-3.0 content
  1762. # that provides additional characteristics of an Element.
  1763. cls._add_property(
  1764. "externalRef",
  1765. ListProp(ObjectProp(ExternalRef, False)),
  1766. iri="https://spdx.org/rdf/3.0.1/terms/Core/externalRef",
  1767. compact="externalRef",
  1768. )
  1769. # Identifies the name of an Element as designated by the creator.
  1770. cls._add_property(
  1771. "name",
  1772. StringProp(),
  1773. iri="https://spdx.org/rdf/3.0.1/terms/Core/name",
  1774. compact="name",
  1775. )
  1776. # A short description of an Element.
  1777. cls._add_property(
  1778. "summary",
  1779. StringProp(),
  1780. iri="https://spdx.org/rdf/3.0.1/terms/Core/summary",
  1781. compact="summary",
  1782. )
  1783. # Provides an IntegrityMethod with which the integrity of an Element can be
  1784. # asserted.
  1785. cls._add_property(
  1786. "verifiedUsing",
  1787. ListProp(ObjectProp(IntegrityMethod, False)),
  1788. iri="https://spdx.org/rdf/3.0.1/terms/Core/verifiedUsing",
  1789. compact="verifiedUsing",
  1790. )
  1791. # A collection of Elements, not necessarily with unifying context.
  1792. @register("https://spdx.org/rdf/3.0.1/terms/Core/ElementCollection", compact_type="ElementCollection", abstract=True)
  1793. class ElementCollection(Element):
  1794. NODE_KIND = NodeKind.IRI
  1795. ID_ALIAS = "spdxId"
  1796. NAMED_INDIVIDUALS = {
  1797. }
  1798. @classmethod
  1799. def _register_props(cls):
  1800. super()._register_props()
  1801. # Refers to one or more Elements that are part of an ElementCollection.
  1802. cls._add_property(
  1803. "element",
  1804. ListProp(ObjectProp(Element, False, context=[
  1805. ("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
  1806. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  1807. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  1808. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  1809. ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
  1810. ],)),
  1811. iri="https://spdx.org/rdf/3.0.1/terms/Core/element",
  1812. compact="element",
  1813. )
  1814. # Describes one a profile which the creator of this ElementCollection intends to
  1815. # conform to.
  1816. cls._add_property(
  1817. "profileConformance",
  1818. ListProp(EnumProp([
  1819. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/ai", "ai"),
  1820. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/build", "build"),
  1821. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/core", "core"),
  1822. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/dataset", "dataset"),
  1823. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/expandedLicensing", "expandedLicensing"),
  1824. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/extension", "extension"),
  1825. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/lite", "lite"),
  1826. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/security", "security"),
  1827. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/simpleLicensing", "simpleLicensing"),
  1828. ("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/software", "software"),
  1829. ])),
  1830. iri="https://spdx.org/rdf/3.0.1/terms/Core/profileConformance",
  1831. compact="profileConformance",
  1832. )
  1833. # This property is used to denote the root Element(s) of a tree of elements contained in a BOM.
  1834. cls._add_property(
  1835. "rootElement",
  1836. ListProp(ObjectProp(Element, False, context=[
  1837. ("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
  1838. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  1839. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  1840. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  1841. ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
  1842. ],)),
  1843. iri="https://spdx.org/rdf/3.0.1/terms/Core/rootElement",
  1844. compact="rootElement",
  1845. )
  1846. # A reference to a resource identifier defined outside the scope of SPDX-3.0 content that uniquely identifies an Element.
  1847. @register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifier", compact_type="ExternalIdentifier", abstract=False)
  1848. class ExternalIdentifier(SHACLObject):
  1849. NODE_KIND = NodeKind.BlankNodeOrIRI
  1850. NAMED_INDIVIDUALS = {
  1851. }
  1852. @classmethod
  1853. def _register_props(cls):
  1854. super()._register_props()
  1855. # Provide consumers with comments by the creator of the Element about the
  1856. # Element.
  1857. cls._add_property(
  1858. "comment",
  1859. StringProp(),
  1860. iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
  1861. compact="comment",
  1862. )
  1863. # Specifies the type of the external identifier.
  1864. cls._add_property(
  1865. "externalIdentifierType",
  1866. EnumProp([
  1867. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe22", "cpe22"),
  1868. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe23", "cpe23"),
  1869. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cve", "cve"),
  1870. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/email", "email"),
  1871. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/gitoid", "gitoid"),
  1872. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/other", "other"),
  1873. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/packageUrl", "packageUrl"),
  1874. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/securityOther", "securityOther"),
  1875. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swhid", "swhid"),
  1876. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swid", "swid"),
  1877. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/urlScheme", "urlScheme"),
  1878. ]),
  1879. iri="https://spdx.org/rdf/3.0.1/terms/Core/externalIdentifierType",
  1880. min_count=1,
  1881. compact="externalIdentifierType",
  1882. )
  1883. # Uniquely identifies an external element.
  1884. cls._add_property(
  1885. "identifier",
  1886. StringProp(),
  1887. iri="https://spdx.org/rdf/3.0.1/terms/Core/identifier",
  1888. min_count=1,
  1889. compact="identifier",
  1890. )
  1891. # Provides the location for more information regarding an external identifier.
  1892. cls._add_property(
  1893. "identifierLocator",
  1894. ListProp(AnyURIProp()),
  1895. iri="https://spdx.org/rdf/3.0.1/terms/Core/identifierLocator",
  1896. compact="identifierLocator",
  1897. )
  1898. # An entity that is authorized to issue identification credentials.
  1899. cls._add_property(
  1900. "issuingAuthority",
  1901. StringProp(),
  1902. iri="https://spdx.org/rdf/3.0.1/terms/Core/issuingAuthority",
  1903. compact="issuingAuthority",
  1904. )
  1905. # Specifies the type of an external identifier.
  1906. @register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType", compact_type="ExternalIdentifierType", abstract=False)
  1907. class ExternalIdentifierType(SHACLObject):
  1908. NODE_KIND = NodeKind.BlankNodeOrIRI
  1909. NAMED_INDIVIDUALS = {
  1910. "cpe22": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe22",
  1911. "cpe23": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe23",
  1912. "cve": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cve",
  1913. "email": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/email",
  1914. "gitoid": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/gitoid",
  1915. "other": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/other",
  1916. "packageUrl": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/packageUrl",
  1917. "securityOther": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/securityOther",
  1918. "swhid": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swhid",
  1919. "swid": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swid",
  1920. "urlScheme": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/urlScheme",
  1921. }
  1922. # [Common Platform Enumeration Specification 2.2](https://cpe.mitre.org/files/cpe-specification_2.2.pdf)
  1923. cpe22 = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe22"
  1924. # [Common Platform Enumeration: Naming Specification Version 2.3](https://csrc.nist.gov/publications/detail/nistir/7695/final)
  1925. cpe23 = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cpe23"
  1926. # Common Vulnerabilities and Exposures identifiers, an identifier for a specific software flaw defined within the official CVE Dictionary and that conforms to the [CVE specification](https://csrc.nist.gov/glossary/term/cve_id).
  1927. cve = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/cve"
  1928. # Email address, as defined in [RFC 3696](https://datatracker.ietf.org/doc/rfc3986/) Section 3.
  1929. email = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/email"
  1930. # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
  1931. gitoid = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/gitoid"
  1932. # Used when the type does not match any of the other options.
  1933. other = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/other"
  1934. # Package URL, as defined in the corresponding [Annex](../../../annexes/pkg-url-specification.md) of this specification.
  1935. packageUrl = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/packageUrl"
  1936. # Used when there is a security related identifier of unspecified type.
  1937. securityOther = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/securityOther"
  1938. # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
  1939. swhid = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swhid"
  1940. # Concise Software Identification (CoSWID) tag, as defined in [RFC 9393](https://datatracker.ietf.org/doc/rfc9393/) Section 2.3.
  1941. swid = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/swid"
  1942. # [Uniform Resource Identifier (URI) Schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml). The scheme used in order to locate a resource.
  1943. urlScheme = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalIdentifierType/urlScheme"
  1944. # A map of Element identifiers that are used within an SpdxDocument but defined
  1945. # external to that SpdxDocument.
  1946. @register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalMap", compact_type="ExternalMap", abstract=False)
  1947. class ExternalMap(SHACLObject):
  1948. NODE_KIND = NodeKind.BlankNodeOrIRI
  1949. NAMED_INDIVIDUALS = {
  1950. }
  1951. @classmethod
  1952. def _register_props(cls):
  1953. super()._register_props()
  1954. # Artifact representing a serialization instance of SPDX data containing the
  1955. # definition of a particular Element.
  1956. cls._add_property(
  1957. "definingArtifact",
  1958. ObjectProp(Artifact, False),
  1959. iri="https://spdx.org/rdf/3.0.1/terms/Core/definingArtifact",
  1960. compact="definingArtifact",
  1961. )
  1962. # Identifies an external Element used within an SpdxDocument but defined
  1963. # external to that SpdxDocument.
  1964. cls._add_property(
  1965. "externalSpdxId",
  1966. AnyURIProp(),
  1967. iri="https://spdx.org/rdf/3.0.1/terms/Core/externalSpdxId",
  1968. min_count=1,
  1969. compact="externalSpdxId",
  1970. )
  1971. # Provides an indication of where to retrieve an external Element.
  1972. cls._add_property(
  1973. "locationHint",
  1974. AnyURIProp(),
  1975. iri="https://spdx.org/rdf/3.0.1/terms/Core/locationHint",
  1976. compact="locationHint",
  1977. )
  1978. # Provides an IntegrityMethod with which the integrity of an Element can be
  1979. # asserted.
  1980. cls._add_property(
  1981. "verifiedUsing",
  1982. ListProp(ObjectProp(IntegrityMethod, False)),
  1983. iri="https://spdx.org/rdf/3.0.1/terms/Core/verifiedUsing",
  1984. compact="verifiedUsing",
  1985. )
  1986. # A reference to a resource outside the scope of SPDX-3.0 content related to an Element.
  1987. @register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRef", compact_type="ExternalRef", abstract=False)
  1988. class ExternalRef(SHACLObject):
  1989. NODE_KIND = NodeKind.BlankNodeOrIRI
  1990. NAMED_INDIVIDUALS = {
  1991. }
  1992. @classmethod
  1993. def _register_props(cls):
  1994. super()._register_props()
  1995. # Provide consumers with comments by the creator of the Element about the
  1996. # Element.
  1997. cls._add_property(
  1998. "comment",
  1999. StringProp(),
  2000. iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
  2001. compact="comment",
  2002. )
  2003. # Provides information about the content type of an Element or a Property.
  2004. cls._add_property(
  2005. "contentType",
  2006. StringProp(pattern=r"^[^\/]+\/[^\/]+$",),
  2007. iri="https://spdx.org/rdf/3.0.1/terms/Core/contentType",
  2008. compact="contentType",
  2009. )
  2010. # Specifies the type of the external reference.
  2011. cls._add_property(
  2012. "externalRefType",
  2013. EnumProp([
  2014. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altDownloadLocation", "altDownloadLocation"),
  2015. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altWebPage", "altWebPage"),
  2016. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/binaryArtifact", "binaryArtifact"),
  2017. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/bower", "bower"),
  2018. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildMeta", "buildMeta"),
  2019. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildSystem", "buildSystem"),
  2020. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/certificationReport", "certificationReport"),
  2021. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/chat", "chat"),
  2022. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/componentAnalysisReport", "componentAnalysisReport"),
  2023. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/cwe", "cwe"),
  2024. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/documentation", "documentation"),
  2025. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/dynamicAnalysisReport", "dynamicAnalysisReport"),
  2026. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/eolNotice", "eolNotice"),
  2027. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/exportControlAssessment", "exportControlAssessment"),
  2028. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/funding", "funding"),
  2029. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/issueTracker", "issueTracker"),
  2030. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/license", "license"),
  2031. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mailingList", "mailingList"),
  2032. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mavenCentral", "mavenCentral"),
  2033. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/metrics", "metrics"),
  2034. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/npm", "npm"),
  2035. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/nuget", "nuget"),
  2036. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/other", "other"),
  2037. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/privacyAssessment", "privacyAssessment"),
  2038. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/productMetadata", "productMetadata"),
  2039. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/purchaseOrder", "purchaseOrder"),
  2040. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/qualityAssessmentReport", "qualityAssessmentReport"),
  2041. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseHistory", "releaseHistory"),
  2042. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseNotes", "releaseNotes"),
  2043. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/riskAssessment", "riskAssessment"),
  2044. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/runtimeAnalysisReport", "runtimeAnalysisReport"),
  2045. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/secureSoftwareAttestation", "secureSoftwareAttestation"),
  2046. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdversaryModel", "securityAdversaryModel"),
  2047. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdvisory", "securityAdvisory"),
  2048. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityFix", "securityFix"),
  2049. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityOther", "securityOther"),
  2050. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPenTestReport", "securityPenTestReport"),
  2051. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPolicy", "securityPolicy"),
  2052. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityThreatModel", "securityThreatModel"),
  2053. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/socialMedia", "socialMedia"),
  2054. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/sourceArtifact", "sourceArtifact"),
  2055. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/staticAnalysisReport", "staticAnalysisReport"),
  2056. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/support", "support"),
  2057. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vcs", "vcs"),
  2058. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityDisclosureReport", "vulnerabilityDisclosureReport"),
  2059. ("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityExploitabilityAssessment", "vulnerabilityExploitabilityAssessment"),
  2060. ]),
  2061. iri="https://spdx.org/rdf/3.0.1/terms/Core/externalRefType",
  2062. compact="externalRefType",
  2063. )
  2064. # Provides the location of an external reference.
  2065. cls._add_property(
  2066. "locator",
  2067. ListProp(StringProp()),
  2068. iri="https://spdx.org/rdf/3.0.1/terms/Core/locator",
  2069. compact="locator",
  2070. )
  2071. # Specifies the type of an external reference.
  2072. @register("https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType", compact_type="ExternalRefType", abstract=False)
  2073. class ExternalRefType(SHACLObject):
  2074. NODE_KIND = NodeKind.BlankNodeOrIRI
  2075. NAMED_INDIVIDUALS = {
  2076. "altDownloadLocation": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altDownloadLocation",
  2077. "altWebPage": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altWebPage",
  2078. "binaryArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/binaryArtifact",
  2079. "bower": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/bower",
  2080. "buildMeta": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildMeta",
  2081. "buildSystem": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildSystem",
  2082. "certificationReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/certificationReport",
  2083. "chat": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/chat",
  2084. "componentAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/componentAnalysisReport",
  2085. "cwe": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/cwe",
  2086. "documentation": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/documentation",
  2087. "dynamicAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/dynamicAnalysisReport",
  2088. "eolNotice": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/eolNotice",
  2089. "exportControlAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/exportControlAssessment",
  2090. "funding": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/funding",
  2091. "issueTracker": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/issueTracker",
  2092. "license": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/license",
  2093. "mailingList": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mailingList",
  2094. "mavenCentral": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mavenCentral",
  2095. "metrics": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/metrics",
  2096. "npm": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/npm",
  2097. "nuget": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/nuget",
  2098. "other": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/other",
  2099. "privacyAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/privacyAssessment",
  2100. "productMetadata": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/productMetadata",
  2101. "purchaseOrder": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/purchaseOrder",
  2102. "qualityAssessmentReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/qualityAssessmentReport",
  2103. "releaseHistory": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseHistory",
  2104. "releaseNotes": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseNotes",
  2105. "riskAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/riskAssessment",
  2106. "runtimeAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/runtimeAnalysisReport",
  2107. "secureSoftwareAttestation": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/secureSoftwareAttestation",
  2108. "securityAdversaryModel": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdversaryModel",
  2109. "securityAdvisory": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdvisory",
  2110. "securityFix": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityFix",
  2111. "securityOther": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityOther",
  2112. "securityPenTestReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPenTestReport",
  2113. "securityPolicy": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPolicy",
  2114. "securityThreatModel": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityThreatModel",
  2115. "socialMedia": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/socialMedia",
  2116. "sourceArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/sourceArtifact",
  2117. "staticAnalysisReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/staticAnalysisReport",
  2118. "support": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/support",
  2119. "vcs": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vcs",
  2120. "vulnerabilityDisclosureReport": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityDisclosureReport",
  2121. "vulnerabilityExploitabilityAssessment": "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityExploitabilityAssessment",
  2122. }
  2123. # A reference to an alternative download location.
  2124. altDownloadLocation = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altDownloadLocation"
  2125. # A reference to an alternative web page.
  2126. altWebPage = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/altWebPage"
  2127. # A reference to binary artifacts related to a package.
  2128. binaryArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/binaryArtifact"
  2129. # A reference to a Bower package. The package locator format, looks like `package#version`, is defined in the "install" section of [Bower API documentation](https://bower.io/docs/api/#install).
  2130. bower = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/bower"
  2131. # A reference build metadata related to a published package.
  2132. buildMeta = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildMeta"
  2133. # A reference build system used to create or publish the package.
  2134. buildSystem = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/buildSystem"
  2135. # A reference to a certification report for a package from an accredited/independent body.
  2136. certificationReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/certificationReport"
  2137. # A reference to the instant messaging system used by the maintainer for a package.
  2138. chat = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/chat"
  2139. # A reference to a Software Composition Analysis (SCA) report.
  2140. componentAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/componentAnalysisReport"
  2141. # [Common Weakness Enumeration](https://csrc.nist.gov/glossary/term/common_weakness_enumeration). A reference to a source of software flaw defined within the official [CWE List](https://cwe.mitre.org/data/) that conforms to the [CWE specification](https://cwe.mitre.org/).
  2142. cwe = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/cwe"
  2143. # A reference to the documentation for a package.
  2144. documentation = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/documentation"
  2145. # A reference to a dynamic analysis report for a package.
  2146. dynamicAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/dynamicAnalysisReport"
  2147. # A reference to the End Of Sale (EOS) and/or End Of Life (EOL) information related to a package.
  2148. eolNotice = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/eolNotice"
  2149. # A reference to a export control assessment for a package.
  2150. exportControlAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/exportControlAssessment"
  2151. # A reference to funding information related to a package.
  2152. funding = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/funding"
  2153. # A reference to the issue tracker for a package.
  2154. issueTracker = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/issueTracker"
  2155. # A reference to additional license information related to an artifact.
  2156. license = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/license"
  2157. # A reference to the mailing list used by the maintainer for a package.
  2158. mailingList = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mailingList"
  2159. # A reference to a Maven repository artifact. The artifact locator format is defined in the [Maven documentation](https://maven.apache.org/guides/mini/guide-naming-conventions.html) and looks like `groupId:artifactId[:version]`.
  2160. mavenCentral = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/mavenCentral"
  2161. # A reference to metrics related to package such as OpenSSF scorecards.
  2162. metrics = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/metrics"
  2163. # A reference to an npm package. The package locator format is defined in the [npm documentation](https://docs.npmjs.com/cli/v10/configuring-npm/package-json) and looks like `package@version`.
  2164. npm = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/npm"
  2165. # A reference to a NuGet package. The package locator format is defined in the [NuGet documentation](https://docs.nuget.org) and looks like `package/version`.
  2166. nuget = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/nuget"
  2167. # Used when the type does not match any of the other options.
  2168. other = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/other"
  2169. # A reference to a privacy assessment for a package.
  2170. privacyAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/privacyAssessment"
  2171. # A reference to additional product metadata such as reference within organization's product catalog.
  2172. productMetadata = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/productMetadata"
  2173. # A reference to a purchase order for a package.
  2174. purchaseOrder = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/purchaseOrder"
  2175. # A reference to a quality assessment for a package.
  2176. qualityAssessmentReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/qualityAssessmentReport"
  2177. # A reference to a published list of releases for a package.
  2178. releaseHistory = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseHistory"
  2179. # A reference to the release notes for a package.
  2180. releaseNotes = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/releaseNotes"
  2181. # A reference to a risk assessment for a package.
  2182. riskAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/riskAssessment"
  2183. # A reference to a runtime analysis report for a package.
  2184. runtimeAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/runtimeAnalysisReport"
  2185. # A reference to information assuring that the software is developed using security practices as defined by [NIST SP 800-218 Secure Software Development Framework (SSDF) Version 1.1](https://csrc.nist.gov/pubs/sp/800/218/final) or [CISA Secure Software Development Attestation Form](https://www.cisa.gov/resources-tools/resources/secure-software-development-attestation-form).
  2186. secureSoftwareAttestation = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/secureSoftwareAttestation"
  2187. # A reference to the security adversary model for a package.
  2188. securityAdversaryModel = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdversaryModel"
  2189. # A reference to a published security advisory (where advisory as defined per [ISO 29147:2018](https://www.iso.org/standard/72311.html)) that may affect one or more elements, e.g., vendor advisories or specific NVD entries.
  2190. securityAdvisory = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityAdvisory"
  2191. # A reference to the patch or source code that fixes a vulnerability.
  2192. securityFix = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityFix"
  2193. # A reference to related security information of unspecified type.
  2194. securityOther = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityOther"
  2195. # A reference to a [penetration test](https://en.wikipedia.org/wiki/Penetration_test) report for a package.
  2196. securityPenTestReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPenTestReport"
  2197. # A reference to instructions for reporting newly discovered security vulnerabilities for a package.
  2198. securityPolicy = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityPolicy"
  2199. # A reference the [security threat model](https://en.wikipedia.org/wiki/Threat_model) for a package.
  2200. securityThreatModel = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/securityThreatModel"
  2201. # A reference to a social media channel for a package.
  2202. socialMedia = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/socialMedia"
  2203. # A reference to an artifact containing the sources for a package.
  2204. sourceArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/sourceArtifact"
  2205. # A reference to a static analysis report for a package.
  2206. staticAnalysisReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/staticAnalysisReport"
  2207. # A reference to the software support channel or other support information for a package.
  2208. support = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/support"
  2209. # A reference to a version control system related to a software artifact.
  2210. vcs = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vcs"
  2211. # A reference to a Vulnerability Disclosure Report (VDR) which provides the software supplier's analysis and findings describing the impact (or lack of impact) that reported vulnerabilities have on packages or products in the supplier's SBOM as defined in [NIST SP 800-161 Cybersecurity Supply Chain Risk Management Practices for Systems and Organizations](https://csrc.nist.gov/pubs/sp/800/161/r1/final).
  2212. vulnerabilityDisclosureReport = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityDisclosureReport"
  2213. # A reference to a Vulnerability Exploitability eXchange (VEX) statement which provides information on whether a product is impacted by a specific vulnerability in an included package and, if affected, whether there are actions recommended to remediate. See also [NTIA VEX one-page summary](https://ntia.gov/files/ntia/publications/vex_one-page_summary.pdf).
  2214. vulnerabilityExploitabilityAssessment = "https://spdx.org/rdf/3.0.1/terms/Core/ExternalRefType/vulnerabilityExploitabilityAssessment"
  2215. # A mathematical algorithm that maps data of arbitrary size to a bit string.
  2216. @register("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm", compact_type="HashAlgorithm", abstract=False)
  2217. class HashAlgorithm(SHACLObject):
  2218. NODE_KIND = NodeKind.BlankNodeOrIRI
  2219. NAMED_INDIVIDUALS = {
  2220. "adler32": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32",
  2221. "blake2b256": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256",
  2222. "blake2b384": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384",
  2223. "blake2b512": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512",
  2224. "blake3": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3",
  2225. "crystalsDilithium": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium",
  2226. "crystalsKyber": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber",
  2227. "falcon": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon",
  2228. "md2": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2",
  2229. "md4": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4",
  2230. "md5": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5",
  2231. "md6": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6",
  2232. "other": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other",
  2233. "sha1": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1",
  2234. "sha224": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224",
  2235. "sha256": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256",
  2236. "sha384": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384",
  2237. "sha3_224": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224",
  2238. "sha3_256": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256",
  2239. "sha3_384": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384",
  2240. "sha3_512": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512",
  2241. "sha512": "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512",
  2242. }
  2243. # Adler-32 checksum is part of the widely used zlib compression library as defined in [RFC 1950](https://datatracker.ietf.org/doc/rfc1950/) Section 2.3.
  2244. adler32 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32"
  2245. # BLAKE2b algorithm with a digest size of 256, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
  2246. blake2b256 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256"
  2247. # BLAKE2b algorithm with a digest size of 384, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
  2248. blake2b384 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384"
  2249. # BLAKE2b algorithm with a digest size of 512, as defined in [RFC 7693](https://datatracker.ietf.org/doc/rfc7693/) Section 4.
  2250. blake2b512 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512"
  2251. # [BLAKE3](https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf)
  2252. blake3 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3"
  2253. # [Dilithium](https://pq-crystals.org/dilithium/)
  2254. crystalsDilithium = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium"
  2255. # [Kyber](https://pq-crystals.org/kyber/)
  2256. crystalsKyber = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber"
  2257. # [FALCON](https://falcon-sign.info/falcon.pdf)
  2258. falcon = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon"
  2259. # MD2 message-digest algorithm, as defined in [RFC 1319](https://datatracker.ietf.org/doc/rfc1319/).
  2260. md2 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2"
  2261. # MD4 message-digest algorithm, as defined in [RFC 1186](https://datatracker.ietf.org/doc/rfc1186/).
  2262. md4 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4"
  2263. # MD5 message-digest algorithm, as defined in [RFC 1321](https://datatracker.ietf.org/doc/rfc1321/).
  2264. md5 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5"
  2265. # [MD6 hash function](https://people.csail.mit.edu/rivest/pubs/RABCx08.pdf)
  2266. md6 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6"
  2267. # any hashing algorithm that does not exist in this list of entries
  2268. other = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other"
  2269. # SHA-1, a secure hashing algorithm, as defined in [RFC 3174](https://datatracker.ietf.org/doc/rfc3174/).
  2270. sha1 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1"
  2271. # SHA-2 with a digest length of 224, as defined in [RFC 3874](https://datatracker.ietf.org/doc/rfc3874/).
  2272. sha224 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224"
  2273. # SHA-2 with a digest length of 256, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
  2274. sha256 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256"
  2275. # SHA-2 with a digest length of 384, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
  2276. sha384 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384"
  2277. # SHA-3 with a digest length of 224, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
  2278. sha3_224 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224"
  2279. # SHA-3 with a digest length of 256, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
  2280. sha3_256 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256"
  2281. # SHA-3 with a digest length of 384, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
  2282. sha3_384 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384"
  2283. # SHA-3 with a digest length of 512, as defined in [FIPS 202](https://csrc.nist.gov/pubs/fips/202/final).
  2284. sha3_512 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512"
  2285. # SHA-2 with a digest length of 512, as defined in [RFC 6234](https://datatracker.ietf.org/doc/rfc6234/).
  2286. sha512 = "https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512"
  2287. # A concrete subclass of Element used by Individuals in the
  2288. # Core profile.
  2289. @register("https://spdx.org/rdf/3.0.1/terms/Core/IndividualElement", compact_type="IndividualElement", abstract=False)
  2290. class IndividualElement(Element):
  2291. NODE_KIND = NodeKind.IRI
  2292. ID_ALIAS = "spdxId"
  2293. NAMED_INDIVIDUALS = {
  2294. "NoAssertionElement": "https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement",
  2295. "NoneElement": "https://spdx.org/rdf/3.0.1/terms/Core/NoneElement",
  2296. }
  2297. # An Individual Value for Element representing a set of Elements of unknown
  2298. # identify or cardinality (number).
  2299. NoAssertionElement = "https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement"
  2300. # An Individual Value for Element representing a set of Elements with
  2301. # cardinality (number/count) of zero.
  2302. NoneElement = "https://spdx.org/rdf/3.0.1/terms/Core/NoneElement"
  2303. # Provides an independently reproducible mechanism that permits verification of a specific Element.
  2304. @register("https://spdx.org/rdf/3.0.1/terms/Core/IntegrityMethod", compact_type="IntegrityMethod", abstract=True)
  2305. class IntegrityMethod(SHACLObject):
  2306. NODE_KIND = NodeKind.BlankNodeOrIRI
  2307. NAMED_INDIVIDUALS = {
  2308. }
  2309. @classmethod
  2310. def _register_props(cls):
  2311. super()._register_props()
  2312. # Provide consumers with comments by the creator of the Element about the
  2313. # Element.
  2314. cls._add_property(
  2315. "comment",
  2316. StringProp(),
  2317. iri="https://spdx.org/rdf/3.0.1/terms/Core/comment",
  2318. compact="comment",
  2319. )
  2320. # Provide an enumerated set of lifecycle phases that can provide context to relationships.
  2321. @register("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType", compact_type="LifecycleScopeType", abstract=False)
  2322. class LifecycleScopeType(SHACLObject):
  2323. NODE_KIND = NodeKind.BlankNodeOrIRI
  2324. NAMED_INDIVIDUALS = {
  2325. "build": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/build",
  2326. "design": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/design",
  2327. "development": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/development",
  2328. "other": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/other",
  2329. "runtime": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/runtime",
  2330. "test": "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/test",
  2331. }
  2332. # A relationship has specific context implications during an element's build phase, during development.
  2333. build = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/build"
  2334. # A relationship has specific context implications during an element's design.
  2335. design = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/design"
  2336. # A relationship has specific context implications during development phase of an element.
  2337. development = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/development"
  2338. # A relationship has other specific context information necessary to capture that the above set of enumerations does not handle.
  2339. other = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/other"
  2340. # A relationship has specific context implications during the execution phase of an element.
  2341. runtime = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/runtime"
  2342. # A relationship has specific context implications during an element's testing phase, during development.
  2343. test = "https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/test"
  2344. # A mapping between prefixes and namespace partial URIs.
  2345. @register("https://spdx.org/rdf/3.0.1/terms/Core/NamespaceMap", compact_type="NamespaceMap", abstract=False)
  2346. class NamespaceMap(SHACLObject):
  2347. NODE_KIND = NodeKind.BlankNodeOrIRI
  2348. NAMED_INDIVIDUALS = {
  2349. }
  2350. @classmethod
  2351. def _register_props(cls):
  2352. super()._register_props()
  2353. # Provides an unambiguous mechanism for conveying a URI fragment portion of an
  2354. # Element ID.
  2355. cls._add_property(
  2356. "namespace",
  2357. AnyURIProp(),
  2358. iri="https://spdx.org/rdf/3.0.1/terms/Core/namespace",
  2359. min_count=1,
  2360. compact="namespace",
  2361. )
  2362. # A substitute for a URI.
  2363. cls._add_property(
  2364. "prefix",
  2365. StringProp(),
  2366. iri="https://spdx.org/rdf/3.0.1/terms/Core/prefix",
  2367. min_count=1,
  2368. compact="prefix",
  2369. )
  2370. # An SPDX version 2.X compatible verification method for software packages.
  2371. @register("https://spdx.org/rdf/3.0.1/terms/Core/PackageVerificationCode", compact_type="PackageVerificationCode", abstract=False)
  2372. class PackageVerificationCode(IntegrityMethod):
  2373. NODE_KIND = NodeKind.BlankNodeOrIRI
  2374. NAMED_INDIVIDUALS = {
  2375. }
  2376. @classmethod
  2377. def _register_props(cls):
  2378. super()._register_props()
  2379. # Specifies the algorithm used for calculating the hash value.
  2380. cls._add_property(
  2381. "algorithm",
  2382. EnumProp([
  2383. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32", "adler32"),
  2384. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256", "blake2b256"),
  2385. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384", "blake2b384"),
  2386. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512", "blake2b512"),
  2387. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3", "blake3"),
  2388. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium", "crystalsDilithium"),
  2389. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber", "crystalsKyber"),
  2390. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon", "falcon"),
  2391. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2", "md2"),
  2392. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4", "md4"),
  2393. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5", "md5"),
  2394. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6", "md6"),
  2395. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other", "other"),
  2396. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1", "sha1"),
  2397. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224", "sha224"),
  2398. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256", "sha256"),
  2399. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384", "sha384"),
  2400. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224", "sha3_224"),
  2401. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256", "sha3_256"),
  2402. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384", "sha3_384"),
  2403. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512", "sha3_512"),
  2404. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512", "sha512"),
  2405. ]),
  2406. iri="https://spdx.org/rdf/3.0.1/terms/Core/algorithm",
  2407. min_count=1,
  2408. compact="algorithm",
  2409. )
  2410. # The result of applying a hash algorithm to an Element.
  2411. cls._add_property(
  2412. "hashValue",
  2413. StringProp(),
  2414. iri="https://spdx.org/rdf/3.0.1/terms/Core/hashValue",
  2415. min_count=1,
  2416. compact="hashValue",
  2417. )
  2418. # The relative file name of a file to be excluded from the
  2419. # `PackageVerificationCode`.
  2420. cls._add_property(
  2421. "packageVerificationCodeExcludedFile",
  2422. ListProp(StringProp()),
  2423. iri="https://spdx.org/rdf/3.0.1/terms/Core/packageVerificationCodeExcludedFile",
  2424. compact="packageVerificationCodeExcludedFile",
  2425. )
  2426. # A tuple of two positive integers that define a range.
  2427. @register("https://spdx.org/rdf/3.0.1/terms/Core/PositiveIntegerRange", compact_type="PositiveIntegerRange", abstract=False)
  2428. class PositiveIntegerRange(SHACLObject):
  2429. NODE_KIND = NodeKind.BlankNodeOrIRI
  2430. NAMED_INDIVIDUALS = {
  2431. }
  2432. @classmethod
  2433. def _register_props(cls):
  2434. super()._register_props()
  2435. # Defines the beginning of a range.
  2436. cls._add_property(
  2437. "beginIntegerRange",
  2438. PositiveIntegerProp(),
  2439. iri="https://spdx.org/rdf/3.0.1/terms/Core/beginIntegerRange",
  2440. min_count=1,
  2441. compact="beginIntegerRange",
  2442. )
  2443. # Defines the end of a range.
  2444. cls._add_property(
  2445. "endIntegerRange",
  2446. PositiveIntegerProp(),
  2447. iri="https://spdx.org/rdf/3.0.1/terms/Core/endIntegerRange",
  2448. min_count=1,
  2449. compact="endIntegerRange",
  2450. )
  2451. # Categories of presence or absence.
  2452. @register("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType", compact_type="PresenceType", abstract=False)
  2453. class PresenceType(SHACLObject):
  2454. NODE_KIND = NodeKind.BlankNodeOrIRI
  2455. NAMED_INDIVIDUALS = {
  2456. "no": "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no",
  2457. "noAssertion": "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion",
  2458. "yes": "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes",
  2459. }
  2460. # Indicates absence of the field.
  2461. no = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no"
  2462. # Makes no assertion about the field.
  2463. noAssertion = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion"
  2464. # Indicates presence of the field.
  2465. yes = "https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes"
  2466. # Enumeration of the valid profiles.
  2467. @register("https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType", compact_type="ProfileIdentifierType", abstract=False)
  2468. class ProfileIdentifierType(SHACLObject):
  2469. NODE_KIND = NodeKind.BlankNodeOrIRI
  2470. NAMED_INDIVIDUALS = {
  2471. "ai": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/ai",
  2472. "build": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/build",
  2473. "core": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/core",
  2474. "dataset": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/dataset",
  2475. "expandedLicensing": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/expandedLicensing",
  2476. "extension": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/extension",
  2477. "lite": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/lite",
  2478. "security": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/security",
  2479. "simpleLicensing": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/simpleLicensing",
  2480. "software": "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/software",
  2481. }
  2482. # the element follows the AI profile specification
  2483. ai = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/ai"
  2484. # the element follows the Build profile specification
  2485. build = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/build"
  2486. # the element follows the Core profile specification
  2487. core = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/core"
  2488. # the element follows the Dataset profile specification
  2489. dataset = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/dataset"
  2490. # the element follows the ExpandedLicensing profile specification
  2491. expandedLicensing = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/expandedLicensing"
  2492. # the element follows the Extension profile specification
  2493. extension = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/extension"
  2494. # the element follows the Lite profile specification
  2495. lite = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/lite"
  2496. # the element follows the Security profile specification
  2497. security = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/security"
  2498. # the element follows the SimpleLicensing profile specification
  2499. simpleLicensing = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/simpleLicensing"
  2500. # the element follows the Software profile specification
  2501. software = "https://spdx.org/rdf/3.0.1/terms/Core/ProfileIdentifierType/software"
  2502. # Describes a relationship between one or more elements.
  2503. @register("https://spdx.org/rdf/3.0.1/terms/Core/Relationship", compact_type="Relationship", abstract=False)
  2504. class Relationship(Element):
  2505. NODE_KIND = NodeKind.IRI
  2506. ID_ALIAS = "spdxId"
  2507. NAMED_INDIVIDUALS = {
  2508. }
  2509. @classmethod
  2510. def _register_props(cls):
  2511. super()._register_props()
  2512. # Provides information about the completeness of relationships.
  2513. cls._add_property(
  2514. "completeness",
  2515. EnumProp([
  2516. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/complete", "complete"),
  2517. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/incomplete", "incomplete"),
  2518. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/noAssertion", "noAssertion"),
  2519. ]),
  2520. iri="https://spdx.org/rdf/3.0.1/terms/Core/completeness",
  2521. compact="completeness",
  2522. )
  2523. # Specifies the time from which an element is no longer applicable / valid.
  2524. cls._add_property(
  2525. "endTime",
  2526. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  2527. iri="https://spdx.org/rdf/3.0.1/terms/Core/endTime",
  2528. compact="endTime",
  2529. )
  2530. # References the Element on the left-hand side of a relationship.
  2531. cls._add_property(
  2532. "from_",
  2533. ObjectProp(Element, True, context=[
  2534. ("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
  2535. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  2536. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  2537. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  2538. ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
  2539. ],),
  2540. iri="https://spdx.org/rdf/3.0.1/terms/Core/from",
  2541. min_count=1,
  2542. compact="from",
  2543. )
  2544. # Information about the relationship between two Elements.
  2545. cls._add_property(
  2546. "relationshipType",
  2547. EnumProp([
  2548. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/affects", "affects"),
  2549. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/amendedBy", "amendedBy"),
  2550. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/ancestorOf", "ancestorOf"),
  2551. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/availableFrom", "availableFrom"),
  2552. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/configures", "configures"),
  2553. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/contains", "contains"),
  2554. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/coordinatedBy", "coordinatedBy"),
  2555. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/copiedTo", "copiedTo"),
  2556. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/delegatedTo", "delegatedTo"),
  2557. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/dependsOn", "dependsOn"),
  2558. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/descendantOf", "descendantOf"),
  2559. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/describes", "describes"),
  2560. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/doesNotAffect", "doesNotAffect"),
  2561. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/expandsTo", "expandsTo"),
  2562. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/exploitCreatedBy", "exploitCreatedBy"),
  2563. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedBy", "fixedBy"),
  2564. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedIn", "fixedIn"),
  2565. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/foundBy", "foundBy"),
  2566. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/generates", "generates"),
  2567. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAddedFile", "hasAddedFile"),
  2568. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssessmentFor", "hasAssessmentFor"),
  2569. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssociatedVulnerability", "hasAssociatedVulnerability"),
  2570. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasConcludedLicense", "hasConcludedLicense"),
  2571. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDataFile", "hasDataFile"),
  2572. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeclaredLicense", "hasDeclaredLicense"),
  2573. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeletedFile", "hasDeletedFile"),
  2574. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDependencyManifest", "hasDependencyManifest"),
  2575. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDistributionArtifact", "hasDistributionArtifact"),
  2576. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDocumentation", "hasDocumentation"),
  2577. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDynamicLink", "hasDynamicLink"),
  2578. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasEvidence", "hasEvidence"),
  2579. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasExample", "hasExample"),
  2580. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasHost", "hasHost"),
  2581. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasInput", "hasInput"),
  2582. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasMetadata", "hasMetadata"),
  2583. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalComponent", "hasOptionalComponent"),
  2584. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalDependency", "hasOptionalDependency"),
  2585. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOutput", "hasOutput"),
  2586. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasPrerequisite", "hasPrerequisite"),
  2587. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasProvidedDependency", "hasProvidedDependency"),
  2588. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasRequirement", "hasRequirement"),
  2589. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasSpecification", "hasSpecification"),
  2590. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasStaticLink", "hasStaticLink"),
  2591. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTest", "hasTest"),
  2592. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTestCase", "hasTestCase"),
  2593. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasVariant", "hasVariant"),
  2594. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/invokedBy", "invokedBy"),
  2595. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/modifiedBy", "modifiedBy"),
  2596. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/other", "other"),
  2597. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/packagedBy", "packagedBy"),
  2598. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/patchedBy", "patchedBy"),
  2599. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/publishedBy", "publishedBy"),
  2600. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/reportedBy", "reportedBy"),
  2601. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/republishedBy", "republishedBy"),
  2602. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/serializedInArtifact", "serializedInArtifact"),
  2603. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/testedOn", "testedOn"),
  2604. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/trainedOn", "trainedOn"),
  2605. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/underInvestigationFor", "underInvestigationFor"),
  2606. ("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/usesTool", "usesTool"),
  2607. ]),
  2608. iri="https://spdx.org/rdf/3.0.1/terms/Core/relationshipType",
  2609. min_count=1,
  2610. compact="relationshipType",
  2611. )
  2612. # Specifies the time from which an element is applicable / valid.
  2613. cls._add_property(
  2614. "startTime",
  2615. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  2616. iri="https://spdx.org/rdf/3.0.1/terms/Core/startTime",
  2617. compact="startTime",
  2618. )
  2619. # References an Element on the right-hand side of a relationship.
  2620. cls._add_property(
  2621. "to",
  2622. ListProp(ObjectProp(Element, False, context=[
  2623. ("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
  2624. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  2625. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  2626. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  2627. ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
  2628. ],)),
  2629. iri="https://spdx.org/rdf/3.0.1/terms/Core/to",
  2630. min_count=1,
  2631. compact="to",
  2632. )
  2633. # Indicates whether a relationship is known to be complete, incomplete, or if no assertion is made with respect to relationship completeness.
  2634. @register("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness", compact_type="RelationshipCompleteness", abstract=False)
  2635. class RelationshipCompleteness(SHACLObject):
  2636. NODE_KIND = NodeKind.BlankNodeOrIRI
  2637. NAMED_INDIVIDUALS = {
  2638. "complete": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/complete",
  2639. "incomplete": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/incomplete",
  2640. "noAssertion": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/noAssertion",
  2641. }
  2642. # The relationship is known to be exhaustive.
  2643. complete = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/complete"
  2644. # The relationship is known not to be exhaustive.
  2645. incomplete = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/incomplete"
  2646. # No assertion can be made about the completeness of the relationship.
  2647. noAssertion = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipCompleteness/noAssertion"
  2648. # Information about the relationship between two Elements.
  2649. @register("https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType", compact_type="RelationshipType", abstract=False)
  2650. class RelationshipType(SHACLObject):
  2651. NODE_KIND = NodeKind.BlankNodeOrIRI
  2652. NAMED_INDIVIDUALS = {
  2653. "affects": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/affects",
  2654. "amendedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/amendedBy",
  2655. "ancestorOf": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/ancestorOf",
  2656. "availableFrom": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/availableFrom",
  2657. "configures": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/configures",
  2658. "contains": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/contains",
  2659. "coordinatedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/coordinatedBy",
  2660. "copiedTo": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/copiedTo",
  2661. "delegatedTo": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/delegatedTo",
  2662. "dependsOn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/dependsOn",
  2663. "descendantOf": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/descendantOf",
  2664. "describes": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/describes",
  2665. "doesNotAffect": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/doesNotAffect",
  2666. "expandsTo": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/expandsTo",
  2667. "exploitCreatedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/exploitCreatedBy",
  2668. "fixedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedBy",
  2669. "fixedIn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedIn",
  2670. "foundBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/foundBy",
  2671. "generates": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/generates",
  2672. "hasAddedFile": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAddedFile",
  2673. "hasAssessmentFor": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssessmentFor",
  2674. "hasAssociatedVulnerability": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssociatedVulnerability",
  2675. "hasConcludedLicense": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasConcludedLicense",
  2676. "hasDataFile": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDataFile",
  2677. "hasDeclaredLicense": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeclaredLicense",
  2678. "hasDeletedFile": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeletedFile",
  2679. "hasDependencyManifest": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDependencyManifest",
  2680. "hasDistributionArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDistributionArtifact",
  2681. "hasDocumentation": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDocumentation",
  2682. "hasDynamicLink": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDynamicLink",
  2683. "hasEvidence": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasEvidence",
  2684. "hasExample": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasExample",
  2685. "hasHost": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasHost",
  2686. "hasInput": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasInput",
  2687. "hasMetadata": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasMetadata",
  2688. "hasOptionalComponent": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalComponent",
  2689. "hasOptionalDependency": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalDependency",
  2690. "hasOutput": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOutput",
  2691. "hasPrerequisite": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasPrerequisite",
  2692. "hasProvidedDependency": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasProvidedDependency",
  2693. "hasRequirement": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasRequirement",
  2694. "hasSpecification": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasSpecification",
  2695. "hasStaticLink": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasStaticLink",
  2696. "hasTest": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTest",
  2697. "hasTestCase": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTestCase",
  2698. "hasVariant": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasVariant",
  2699. "invokedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/invokedBy",
  2700. "modifiedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/modifiedBy",
  2701. "other": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/other",
  2702. "packagedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/packagedBy",
  2703. "patchedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/patchedBy",
  2704. "publishedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/publishedBy",
  2705. "reportedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/reportedBy",
  2706. "republishedBy": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/republishedBy",
  2707. "serializedInArtifact": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/serializedInArtifact",
  2708. "testedOn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/testedOn",
  2709. "trainedOn": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/trainedOn",
  2710. "underInvestigationFor": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/underInvestigationFor",
  2711. "usesTool": "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/usesTool",
  2712. }
  2713. # The `from` Vulnerability affects each `to` Element. The use of the `affects` type is constrained to `VexAffectedVulnAssessmentRelationship` classed relationships.
  2714. affects = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/affects"
  2715. # The `from` Element is amended by each `to` Element.
  2716. amendedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/amendedBy"
  2717. # The `from` Element is an ancestor of each `to` Element.
  2718. ancestorOf = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/ancestorOf"
  2719. # The `from` Element is available from the additional supplier described by each `to` Element.
  2720. availableFrom = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/availableFrom"
  2721. # The `from` Element is a configuration applied to each `to` Element, during a LifecycleScopeType period.
  2722. configures = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/configures"
  2723. # The `from` Element contains each `to` Element.
  2724. contains = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/contains"
  2725. # The `from` Vulnerability is coordinatedBy the `to` Agent(s) (vendor, researcher, or consumer agent).
  2726. coordinatedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/coordinatedBy"
  2727. # The `from` Element has been copied to each `to` Element.
  2728. copiedTo = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/copiedTo"
  2729. # The `from` Agent is delegating an action to the Agent of the `to` Relationship (which must be of type invokedBy), during a LifecycleScopeType (e.g. the `to` invokedBy Relationship is being done on behalf of `from`).
  2730. delegatedTo = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/delegatedTo"
  2731. # The `from` Element depends on each `to` Element, during a LifecycleScopeType period.
  2732. dependsOn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/dependsOn"
  2733. # The `from` Element is a descendant of each `to` Element.
  2734. descendantOf = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/descendantOf"
  2735. # The `from` Element describes each `to` Element. To denote the root(s) of a tree of elements in a collection, the rootElement property should be used.
  2736. describes = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/describes"
  2737. # The `from` Vulnerability has no impact on each `to` Element. The use of the `doesNotAffect` is constrained to `VexNotAffectedVulnAssessmentRelationship` classed relationships.
  2738. doesNotAffect = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/doesNotAffect"
  2739. # The `from` archive expands out as an artifact described by each `to` Element.
  2740. expandsTo = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/expandsTo"
  2741. # The `from` Vulnerability has had an exploit created against it by each `to` Agent.
  2742. exploitCreatedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/exploitCreatedBy"
  2743. # Designates a `from` Vulnerability has been fixed by the `to` Agent(s).
  2744. fixedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedBy"
  2745. # A `from` Vulnerability has been fixed in each `to` Element. The use of the `fixedIn` type is constrained to `VexFixedVulnAssessmentRelationship` classed relationships.
  2746. fixedIn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/fixedIn"
  2747. # Designates a `from` Vulnerability was originally discovered by the `to` Agent(s).
  2748. foundBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/foundBy"
  2749. # The `from` Element generates each `to` Element.
  2750. generates = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/generates"
  2751. # Every `to` Element is a file added to the `from` Element (`from` hasAddedFile `to`).
  2752. hasAddedFile = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAddedFile"
  2753. # Relates a `from` Vulnerability and each `to` Element with a security assessment. To be used with `VulnAssessmentRelationship` types.
  2754. hasAssessmentFor = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssessmentFor"
  2755. # Used to associate a `from` Artifact with each `to` Vulnerability.
  2756. hasAssociatedVulnerability = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasAssociatedVulnerability"
  2757. # The `from` SoftwareArtifact is concluded by the SPDX data creator to be governed by each `to` license.
  2758. hasConcludedLicense = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasConcludedLicense"
  2759. # The `from` Element treats each `to` Element as a data file. A data file is an artifact that stores data required or optional for the `from` Element's functionality. A data file can be a database file, an index file, a log file, an AI model file, a calibration data file, a temporary file, a backup file, and more. For AI training dataset, test dataset, test artifact, configuration data, build input data, and build output data, please consider using the more specific relationship types: `trainedOn`, `testedOn`, `hasTest`, `configures`, `hasInput`, and `hasOutput`, respectively. This relationship does not imply dependency.
  2760. hasDataFile = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDataFile"
  2761. # The `from` SoftwareArtifact was discovered to actually contain each `to` license, for example as detected by use of automated tooling.
  2762. hasDeclaredLicense = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeclaredLicense"
  2763. # Every `to` Element is a file deleted from the `from` Element (`from` hasDeletedFile `to`).
  2764. hasDeletedFile = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDeletedFile"
  2765. # The `from` Element has manifest files that contain dependency information in each `to` Element.
  2766. hasDependencyManifest = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDependencyManifest"
  2767. # The `from` Element is distributed as an artifact in each `to` Element (e.g. an RPM or archive file).
  2768. hasDistributionArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDistributionArtifact"
  2769. # The `from` Element is documented by each `to` Element.
  2770. hasDocumentation = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDocumentation"
  2771. # The `from` Element dynamically links in each `to` Element, during a LifecycleScopeType period.
  2772. hasDynamicLink = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasDynamicLink"
  2773. # Every `to` Element is considered as evidence for the `from` Element (`from` hasEvidence `to`).
  2774. hasEvidence = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasEvidence"
  2775. # Every `to` Element is an example for the `from` Element (`from` hasExample `to`).
  2776. hasExample = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasExample"
  2777. # The `from` Build was run on the `to` Element during a LifecycleScopeType period (e.g. the host that the build runs on).
  2778. hasHost = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasHost"
  2779. # The `from` Build has each `to` Element as an input, during a LifecycleScopeType period.
  2780. hasInput = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasInput"
  2781. # Every `to` Element is metadata about the `from` Element (`from` hasMetadata `to`).
  2782. hasMetadata = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasMetadata"
  2783. # Every `to` Element is an optional component of the `from` Element (`from` hasOptionalComponent `to`).
  2784. hasOptionalComponent = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalComponent"
  2785. # The `from` Element optionally depends on each `to` Element, during a LifecycleScopeType period.
  2786. hasOptionalDependency = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOptionalDependency"
  2787. # The `from` Build element generates each `to` Element as an output, during a LifecycleScopeType period.
  2788. hasOutput = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasOutput"
  2789. # The `from` Element has a prerequisite on each `to` Element, during a LifecycleScopeType period.
  2790. hasPrerequisite = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasPrerequisite"
  2791. # The `from` Element has a dependency on each `to` Element, dependency is not in the distributed artifact, but assumed to be provided, during a LifecycleScopeType period.
  2792. hasProvidedDependency = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasProvidedDependency"
  2793. # The `from` Element has a requirement on each `to` Element, during a LifecycleScopeType period.
  2794. hasRequirement = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasRequirement"
  2795. # Every `to` Element is a specification for the `from` Element (`from` hasSpecification `to`), during a LifecycleScopeType period.
  2796. hasSpecification = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasSpecification"
  2797. # The `from` Element statically links in each `to` Element, during a LifecycleScopeType period.
  2798. hasStaticLink = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasStaticLink"
  2799. # Every `to` Element is a test artifact for the `from` Element (`from` hasTest `to`), during a LifecycleScopeType period.
  2800. hasTest = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTest"
  2801. # Every `to` Element is a test case for the `from` Element (`from` hasTestCase `to`).
  2802. hasTestCase = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasTestCase"
  2803. # Every `to` Element is a variant the `from` Element (`from` hasVariant `to`).
  2804. hasVariant = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/hasVariant"
  2805. # The `from` Element was invoked by the `to` Agent, during a LifecycleScopeType period (for example, a Build element that describes a build step).
  2806. invokedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/invokedBy"
  2807. # The `from` Element is modified by each `to` Element.
  2808. modifiedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/modifiedBy"
  2809. # Every `to` Element is related to the `from` Element where the relationship type is not described by any of the SPDX relationship types (this relationship is directionless).
  2810. other = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/other"
  2811. # Every `to` Element is a packaged instance of the `from` Element (`from` packagedBy `to`).
  2812. packagedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/packagedBy"
  2813. # Every `to` Element is a patch for the `from` Element (`from` patchedBy `to`).
  2814. patchedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/patchedBy"
  2815. # Designates a `from` Vulnerability was made available for public use or reference by each `to` Agent.
  2816. publishedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/publishedBy"
  2817. # Designates a `from` Vulnerability was first reported to a project, vendor, or tracking database for formal identification by each `to` Agent.
  2818. reportedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/reportedBy"
  2819. # Designates a `from` Vulnerability's details were tracked, aggregated, and/or enriched to improve context (i.e. NVD) by each `to` Agent.
  2820. republishedBy = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/republishedBy"
  2821. # The `from` SpdxDocument can be found in a serialized form in each `to` Artifact.
  2822. serializedInArtifact = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/serializedInArtifact"
  2823. # The `from` Element has been tested on the `to` Element(s).
  2824. testedOn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/testedOn"
  2825. # The `from` Element has been trained on the `to` Element(s).
  2826. trainedOn = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/trainedOn"
  2827. # The `from` Vulnerability impact is being investigated for each `to` Element. The use of the `underInvestigationFor` type is constrained to `VexUnderInvestigationVulnAssessmentRelationship` classed relationships.
  2828. underInvestigationFor = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/underInvestigationFor"
  2829. # The `from` Element uses each `to` Element as a tool, during a LifecycleScopeType period.
  2830. usesTool = "https://spdx.org/rdf/3.0.1/terms/Core/RelationshipType/usesTool"
  2831. # A collection of SPDX Elements that could potentially be serialized.
  2832. @register("https://spdx.org/rdf/3.0.1/terms/Core/SpdxDocument", compact_type="SpdxDocument", abstract=False)
  2833. class SpdxDocument(ElementCollection):
  2834. NODE_KIND = NodeKind.IRI
  2835. ID_ALIAS = "spdxId"
  2836. NAMED_INDIVIDUALS = {
  2837. }
  2838. @classmethod
  2839. def _register_props(cls):
  2840. super()._register_props()
  2841. # Provides the license under which the SPDX documentation of the Element can be
  2842. # used.
  2843. cls._add_property(
  2844. "dataLicense",
  2845. ObjectProp(simplelicensing_AnyLicenseInfo, False, context=[
  2846. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  2847. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  2848. ],),
  2849. iri="https://spdx.org/rdf/3.0.1/terms/Core/dataLicense",
  2850. compact="dataLicense",
  2851. )
  2852. # Provides an ExternalMap of Element identifiers.
  2853. cls._add_property(
  2854. "import_",
  2855. ListProp(ObjectProp(ExternalMap, False)),
  2856. iri="https://spdx.org/rdf/3.0.1/terms/Core/import",
  2857. compact="import",
  2858. )
  2859. # Provides a NamespaceMap of prefixes and associated namespace partial URIs applicable to an SpdxDocument and independent of any specific serialization format or instance.
  2860. cls._add_property(
  2861. "namespaceMap",
  2862. ListProp(ObjectProp(NamespaceMap, False)),
  2863. iri="https://spdx.org/rdf/3.0.1/terms/Core/namespaceMap",
  2864. compact="namespaceMap",
  2865. )
  2866. # Indicates the type of support that is associated with an artifact.
  2867. @register("https://spdx.org/rdf/3.0.1/terms/Core/SupportType", compact_type="SupportType", abstract=False)
  2868. class SupportType(SHACLObject):
  2869. NODE_KIND = NodeKind.BlankNodeOrIRI
  2870. NAMED_INDIVIDUALS = {
  2871. "deployed": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/deployed",
  2872. "development": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/development",
  2873. "endOfSupport": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/endOfSupport",
  2874. "limitedSupport": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/limitedSupport",
  2875. "noAssertion": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noAssertion",
  2876. "noSupport": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noSupport",
  2877. "support": "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/support",
  2878. }
  2879. # in addition to being supported by the supplier, the software is known to have been deployed and is in use. For a software as a service provider, this implies the software is now available as a service.
  2880. deployed = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/deployed"
  2881. # the artifact is in active development and is not considered ready for formal support from the supplier.
  2882. development = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/development"
  2883. # there is a defined end of support for the artifact from the supplier. This may also be referred to as end of life. There is a validUntilDate that can be used to signal when support ends for the artifact.
  2884. endOfSupport = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/endOfSupport"
  2885. # the artifact has been released, and there is limited support available from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
  2886. limitedSupport = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/limitedSupport"
  2887. # no assertion about the type of support is made. This is considered the default if no other support type is used.
  2888. noAssertion = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noAssertion"
  2889. # there is no support for the artifact from the supplier, consumer assumes any support obligations.
  2890. noSupport = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noSupport"
  2891. # the artifact has been released, and is supported from the supplier. There is a validUntilDate that can provide additional information about the duration of support.
  2892. support = "https://spdx.org/rdf/3.0.1/terms/Core/SupportType/support"
  2893. # An element of hardware and/or software utilized to carry out a particular function.
  2894. @register("https://spdx.org/rdf/3.0.1/terms/Core/Tool", compact_type="Tool", abstract=False)
  2895. class Tool(Element):
  2896. NODE_KIND = NodeKind.IRI
  2897. ID_ALIAS = "spdxId"
  2898. NAMED_INDIVIDUALS = {
  2899. }
  2900. # Categories of confidentiality level.
  2901. @register("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType", compact_type="dataset_ConfidentialityLevelType", abstract=False)
  2902. class dataset_ConfidentialityLevelType(SHACLObject):
  2903. NODE_KIND = NodeKind.BlankNodeOrIRI
  2904. NAMED_INDIVIDUALS = {
  2905. "amber": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/amber",
  2906. "clear": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/clear",
  2907. "green": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/green",
  2908. "red": "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/red",
  2909. }
  2910. # Data points in the dataset can be shared only with specific organizations and their clients on a need to know basis.
  2911. amber = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/amber"
  2912. # Dataset may be distributed freely, without restriction.
  2913. clear = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/clear"
  2914. # Dataset can be shared within a community of peers and partners.
  2915. green = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/green"
  2916. # Data points in the dataset are highly confidential and can only be shared with named recipients.
  2917. red = "https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/red"
  2918. # Availability of dataset.
  2919. @register("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType", compact_type="dataset_DatasetAvailabilityType", abstract=False)
  2920. class dataset_DatasetAvailabilityType(SHACLObject):
  2921. NODE_KIND = NodeKind.BlankNodeOrIRI
  2922. NAMED_INDIVIDUALS = {
  2923. "clickthrough": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/clickthrough",
  2924. "directDownload": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/directDownload",
  2925. "query": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/query",
  2926. "registration": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/registration",
  2927. "scrapingScript": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/scrapingScript",
  2928. }
  2929. # the dataset is not publicly available and can only be accessed after affirmatively accepting terms on a clickthrough webpage.
  2930. clickthrough = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/clickthrough"
  2931. # the dataset is publicly available and can be downloaded directly.
  2932. directDownload = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/directDownload"
  2933. # the dataset is publicly available, but not all at once, and can only be accessed through queries which return parts of the dataset.
  2934. query = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/query"
  2935. # the dataset is not publicly available and an email registration is required before accessing the dataset, although without an affirmative acceptance of terms.
  2936. registration = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/registration"
  2937. # the dataset provider is not making available the underlying data and the dataset must be reassembled, typically using the provided script for scraping the data.
  2938. scrapingScript = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/scrapingScript"
  2939. # Enumeration of dataset types.
  2940. @register("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType", compact_type="dataset_DatasetType", abstract=False)
  2941. class dataset_DatasetType(SHACLObject):
  2942. NODE_KIND = NodeKind.BlankNodeOrIRI
  2943. NAMED_INDIVIDUALS = {
  2944. "audio": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/audio",
  2945. "categorical": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/categorical",
  2946. "graph": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/graph",
  2947. "image": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/image",
  2948. "noAssertion": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/noAssertion",
  2949. "numeric": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/numeric",
  2950. "other": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/other",
  2951. "sensor": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/sensor",
  2952. "structured": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/structured",
  2953. "syntactic": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/syntactic",
  2954. "text": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/text",
  2955. "timeseries": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timeseries",
  2956. "timestamp": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timestamp",
  2957. "video": "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/video",
  2958. }
  2959. # data is audio based, such as a collection of music from the 80s.
  2960. audio = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/audio"
  2961. # data that is classified into a discrete number of categories, such as the eye color of a population of people.
  2962. categorical = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/categorical"
  2963. # data is in the form of a graph where entries are somehow related to each other through edges, such a social network of friends.
  2964. graph = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/graph"
  2965. # data is a collection of images such as pictures of animals.
  2966. image = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/image"
  2967. # data type is not known.
  2968. noAssertion = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/noAssertion"
  2969. # data consists only of numeric entries.
  2970. numeric = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/numeric"
  2971. # data is of a type not included in this list.
  2972. other = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/other"
  2973. # data is recorded from a physical sensor, such as a thermometer reading or biometric device.
  2974. sensor = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/sensor"
  2975. # data is stored in tabular format or retrieved from a relational database.
  2976. structured = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/structured"
  2977. # data describes the syntax or semantics of a language or text, such as a parse tree used for natural language processing.
  2978. syntactic = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/syntactic"
  2979. # data consists of unstructured text, such as a book, Wikipedia article (without images), or transcript.
  2980. text = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/text"
  2981. # data is recorded in an ordered sequence of timestamped entries, such as the price of a stock over the course of a day.
  2982. timeseries = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timeseries"
  2983. # data is recorded with a timestamp for each entry, but not necessarily ordered or at specific intervals, such as when a taxi ride starts and ends.
  2984. timestamp = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timestamp"
  2985. # data is video based, such as a collection of movie clips featuring Tom Hanks.
  2986. video = "https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/video"
  2987. # Abstract class for additional text intended to be added to a License, but
  2988. # which is not itself a standalone License.
  2989. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/LicenseAddition", compact_type="expandedlicensing_LicenseAddition", abstract=True)
  2990. class expandedlicensing_LicenseAddition(Element):
  2991. NODE_KIND = NodeKind.IRI
  2992. ID_ALIAS = "spdxId"
  2993. NAMED_INDIVIDUALS = {
  2994. }
  2995. @classmethod
  2996. def _register_props(cls):
  2997. super()._register_props()
  2998. # Identifies the full text of a LicenseAddition.
  2999. cls._add_property(
  3000. "expandedlicensing_additionText",
  3001. StringProp(),
  3002. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/additionText",
  3003. min_count=1,
  3004. compact="expandedlicensing_additionText",
  3005. )
  3006. # Specifies whether an additional text identifier has been marked as deprecated.
  3007. cls._add_property(
  3008. "expandedlicensing_isDeprecatedAdditionId",
  3009. BooleanProp(),
  3010. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isDeprecatedAdditionId",
  3011. compact="expandedlicensing_isDeprecatedAdditionId",
  3012. )
  3013. # Identifies all the text and metadata associated with a license in the license
  3014. # XML format.
  3015. cls._add_property(
  3016. "expandedlicensing_licenseXml",
  3017. StringProp(),
  3018. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/licenseXml",
  3019. compact="expandedlicensing_licenseXml",
  3020. )
  3021. # Specifies the licenseId that is preferred to be used in place of a deprecated
  3022. # License or LicenseAddition.
  3023. cls._add_property(
  3024. "expandedlicensing_obsoletedBy",
  3025. StringProp(),
  3026. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/obsoletedBy",
  3027. compact="expandedlicensing_obsoletedBy",
  3028. )
  3029. # Contains a URL where the License or LicenseAddition can be found in use.
  3030. cls._add_property(
  3031. "expandedlicensing_seeAlso",
  3032. ListProp(AnyURIProp()),
  3033. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/seeAlso",
  3034. compact="expandedlicensing_seeAlso",
  3035. )
  3036. # Identifies the full text of a LicenseAddition, in SPDX templating format.
  3037. cls._add_property(
  3038. "expandedlicensing_standardAdditionTemplate",
  3039. StringProp(),
  3040. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/standardAdditionTemplate",
  3041. compact="expandedlicensing_standardAdditionTemplate",
  3042. )
  3043. # A license exception that is listed on the SPDX Exceptions list.
  3044. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicenseException", compact_type="expandedlicensing_ListedLicenseException", abstract=False)
  3045. class expandedlicensing_ListedLicenseException(expandedlicensing_LicenseAddition):
  3046. NODE_KIND = NodeKind.IRI
  3047. ID_ALIAS = "spdxId"
  3048. NAMED_INDIVIDUALS = {
  3049. }
  3050. @classmethod
  3051. def _register_props(cls):
  3052. super()._register_props()
  3053. # Specifies the SPDX License List version in which this license or exception
  3054. # identifier was deprecated.
  3055. cls._add_property(
  3056. "expandedlicensing_deprecatedVersion",
  3057. StringProp(),
  3058. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/deprecatedVersion",
  3059. compact="expandedlicensing_deprecatedVersion",
  3060. )
  3061. # Specifies the SPDX License List version in which this ListedLicense or
  3062. # ListedLicenseException identifier was first added.
  3063. cls._add_property(
  3064. "expandedlicensing_listVersionAdded",
  3065. StringProp(),
  3066. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/listVersionAdded",
  3067. compact="expandedlicensing_listVersionAdded",
  3068. )
  3069. # A property name with an associated value.
  3070. @register("https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertyEntry", compact_type="extension_CdxPropertyEntry", abstract=False)
  3071. class extension_CdxPropertyEntry(SHACLObject):
  3072. NODE_KIND = NodeKind.BlankNodeOrIRI
  3073. NAMED_INDIVIDUALS = {
  3074. }
  3075. @classmethod
  3076. def _register_props(cls):
  3077. super()._register_props()
  3078. # A name used in a CdxPropertyEntry name-value pair.
  3079. cls._add_property(
  3080. "extension_cdxPropName",
  3081. StringProp(),
  3082. iri="https://spdx.org/rdf/3.0.1/terms/Extension/cdxPropName",
  3083. min_count=1,
  3084. compact="extension_cdxPropName",
  3085. )
  3086. # A value used in a CdxPropertyEntry name-value pair.
  3087. cls._add_property(
  3088. "extension_cdxPropValue",
  3089. StringProp(),
  3090. iri="https://spdx.org/rdf/3.0.1/terms/Extension/cdxPropValue",
  3091. compact="extension_cdxPropValue",
  3092. )
  3093. # A characterization of some aspect of an Element that is associated with the Element in a generalized fashion.
  3094. @register("https://spdx.org/rdf/3.0.1/terms/Extension/Extension", compact_type="extension_Extension", abstract=True)
  3095. class extension_Extension(SHACLExtensibleObject, SHACLObject):
  3096. NODE_KIND = NodeKind.BlankNodeOrIRI
  3097. NAMED_INDIVIDUALS = {
  3098. }
  3099. # Specifies the CVSS base, temporal, threat, or environmental severity type.
  3100. @register("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType", compact_type="security_CvssSeverityType", abstract=False)
  3101. class security_CvssSeverityType(SHACLObject):
  3102. NODE_KIND = NodeKind.BlankNodeOrIRI
  3103. NAMED_INDIVIDUALS = {
  3104. "critical": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical",
  3105. "high": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high",
  3106. "low": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low",
  3107. "medium": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium",
  3108. "none": "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none",
  3109. }
  3110. # When a CVSS score is between 9.0 - 10.0
  3111. critical = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical"
  3112. # When a CVSS score is between 7.0 - 8.9
  3113. high = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high"
  3114. # When a CVSS score is between 0.1 - 3.9
  3115. low = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low"
  3116. # When a CVSS score is between 4.0 - 6.9
  3117. medium = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium"
  3118. # When a CVSS score is 0.0
  3119. none = "https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none"
  3120. # Specifies the exploit catalog type.
  3121. @register("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType", compact_type="security_ExploitCatalogType", abstract=False)
  3122. class security_ExploitCatalogType(SHACLObject):
  3123. NODE_KIND = NodeKind.BlankNodeOrIRI
  3124. NAMED_INDIVIDUALS = {
  3125. "kev": "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/kev",
  3126. "other": "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/other",
  3127. }
  3128. # CISA's Known Exploited Vulnerability (KEV) Catalog
  3129. kev = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/kev"
  3130. # Other exploit catalogs
  3131. other = "https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/other"
  3132. # Specifies the SSVC decision type.
  3133. @register("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType", compact_type="security_SsvcDecisionType", abstract=False)
  3134. class security_SsvcDecisionType(SHACLObject):
  3135. NODE_KIND = NodeKind.BlankNodeOrIRI
  3136. NAMED_INDIVIDUALS = {
  3137. "act": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/act",
  3138. "attend": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/attend",
  3139. "track": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/track",
  3140. "trackStar": "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/trackStar",
  3141. }
  3142. # The vulnerability requires attention from the organization's internal, supervisory-level and leadership-level individuals. Necessary actions include requesting assistance or information about the vulnerability, as well as publishing a notification either internally and/or externally. Typically, internal groups would meet to determine the overall response and then execute agreed upon actions. CISA recommends remediating Act vulnerabilities as soon as possible.
  3143. act = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/act"
  3144. # The vulnerability requires attention from the organization's internal, supervisory-level individuals. Necessary actions include requesting assistance or information about the vulnerability, and may involve publishing a notification either internally and/or externally. CISA recommends remediating Attend vulnerabilities sooner than standard update timelines.
  3145. attend = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/attend"
  3146. # The vulnerability does not require action at this time. The organization would continue to track the vulnerability and reassess it if new information becomes available. CISA recommends remediating Track vulnerabilities within standard update timelines.
  3147. track = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/track"
  3148. # ("Track\*" in the SSVC spec) The vulnerability contains specific characteristics that may require closer monitoring for changes. CISA recommends remediating Track\* vulnerabilities within standard update timelines.
  3149. trackStar = "https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/trackStar"
  3150. # Specifies the VEX justification type.
  3151. @register("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType", compact_type="security_VexJustificationType", abstract=False)
  3152. class security_VexJustificationType(SHACLObject):
  3153. NODE_KIND = NodeKind.BlankNodeOrIRI
  3154. NAMED_INDIVIDUALS = {
  3155. "componentNotPresent": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/componentNotPresent",
  3156. "inlineMitigationsAlreadyExist": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/inlineMitigationsAlreadyExist",
  3157. "vulnerableCodeCannotBeControlledByAdversary": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeCannotBeControlledByAdversary",
  3158. "vulnerableCodeNotInExecutePath": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotInExecutePath",
  3159. "vulnerableCodeNotPresent": "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotPresent",
  3160. }
  3161. # The software is not affected because the vulnerable component is not in the product.
  3162. componentNotPresent = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/componentNotPresent"
  3163. # Built-in inline controls or mitigations prevent an adversary from leveraging the vulnerability.
  3164. inlineMitigationsAlreadyExist = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/inlineMitigationsAlreadyExist"
  3165. # The vulnerable component is present, and the component contains the vulnerable code. However, vulnerable code is used in such a way that an attacker cannot mount any anticipated attack.
  3166. vulnerableCodeCannotBeControlledByAdversary = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeCannotBeControlledByAdversary"
  3167. # The affected code is not reachable through the execution of the code, including non-anticipated states of the product.
  3168. vulnerableCodeNotInExecutePath = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotInExecutePath"
  3169. # The product is not affected because the code underlying the vulnerability is not present in the product.
  3170. vulnerableCodeNotPresent = "https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotPresent"
  3171. # Abstract ancestor class for all vulnerability assessments
  3172. @register("https://spdx.org/rdf/3.0.1/terms/Security/VulnAssessmentRelationship", compact_type="security_VulnAssessmentRelationship", abstract=True)
  3173. class security_VulnAssessmentRelationship(Relationship):
  3174. NODE_KIND = NodeKind.IRI
  3175. ID_ALIAS = "spdxId"
  3176. NAMED_INDIVIDUALS = {
  3177. }
  3178. @classmethod
  3179. def _register_props(cls):
  3180. super()._register_props()
  3181. # Identifies who or what supplied the artifact or VulnAssessmentRelationship
  3182. # referenced by the Element.
  3183. cls._add_property(
  3184. "suppliedBy",
  3185. ObjectProp(Agent, False, context=[
  3186. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  3187. ],),
  3188. iri="https://spdx.org/rdf/3.0.1/terms/Core/suppliedBy",
  3189. compact="suppliedBy",
  3190. )
  3191. # Specifies an Element contained in a piece of software where a vulnerability was
  3192. # found.
  3193. cls._add_property(
  3194. "security_assessedElement",
  3195. ObjectProp(software_SoftwareArtifact, False),
  3196. iri="https://spdx.org/rdf/3.0.1/terms/Security/assessedElement",
  3197. compact="security_assessedElement",
  3198. )
  3199. # Specifies a time when a vulnerability assessment was modified
  3200. cls._add_property(
  3201. "security_modifiedTime",
  3202. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3203. iri="https://spdx.org/rdf/3.0.1/terms/Security/modifiedTime",
  3204. compact="security_modifiedTime",
  3205. )
  3206. # Specifies the time when a vulnerability was published.
  3207. cls._add_property(
  3208. "security_publishedTime",
  3209. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3210. iri="https://spdx.org/rdf/3.0.1/terms/Security/publishedTime",
  3211. compact="security_publishedTime",
  3212. )
  3213. # Specified the time and date when a vulnerability was withdrawn.
  3214. cls._add_property(
  3215. "security_withdrawnTime",
  3216. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3217. iri="https://spdx.org/rdf/3.0.1/terms/Security/withdrawnTime",
  3218. compact="security_withdrawnTime",
  3219. )
  3220. # Abstract class representing a license combination consisting of one or more licenses.
  3221. @register("https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/AnyLicenseInfo", compact_type="simplelicensing_AnyLicenseInfo", abstract=True)
  3222. class simplelicensing_AnyLicenseInfo(Element):
  3223. NODE_KIND = NodeKind.IRI
  3224. ID_ALIAS = "spdxId"
  3225. NAMED_INDIVIDUALS = {
  3226. }
  3227. # An SPDX Element containing an SPDX license expression string.
  3228. @register("https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/LicenseExpression", compact_type="simplelicensing_LicenseExpression", abstract=False)
  3229. class simplelicensing_LicenseExpression(simplelicensing_AnyLicenseInfo):
  3230. NODE_KIND = NodeKind.IRI
  3231. ID_ALIAS = "spdxId"
  3232. NAMED_INDIVIDUALS = {
  3233. }
  3234. @classmethod
  3235. def _register_props(cls):
  3236. super()._register_props()
  3237. # Maps a LicenseRef or AdditionRef string for a Custom License or a Custom
  3238. # License Addition to its URI ID.
  3239. cls._add_property(
  3240. "simplelicensing_customIdToUri",
  3241. ListProp(ObjectProp(DictionaryEntry, False)),
  3242. iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/customIdToUri",
  3243. compact="simplelicensing_customIdToUri",
  3244. )
  3245. # A string in the license expression format.
  3246. cls._add_property(
  3247. "simplelicensing_licenseExpression",
  3248. StringProp(),
  3249. iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseExpression",
  3250. min_count=1,
  3251. compact="simplelicensing_licenseExpression",
  3252. )
  3253. # The version of the SPDX License List used in the license expression.
  3254. cls._add_property(
  3255. "simplelicensing_licenseListVersion",
  3256. StringProp(pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$",),
  3257. iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseListVersion",
  3258. compact="simplelicensing_licenseListVersion",
  3259. )
  3260. # A license or addition that is not listed on the SPDX License List.
  3261. @register("https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/SimpleLicensingText", compact_type="simplelicensing_SimpleLicensingText", abstract=False)
  3262. class simplelicensing_SimpleLicensingText(Element):
  3263. NODE_KIND = NodeKind.IRI
  3264. ID_ALIAS = "spdxId"
  3265. NAMED_INDIVIDUALS = {
  3266. }
  3267. @classmethod
  3268. def _register_props(cls):
  3269. super()._register_props()
  3270. # Identifies the full text of a License or Addition.
  3271. cls._add_property(
  3272. "simplelicensing_licenseText",
  3273. StringProp(),
  3274. iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseText",
  3275. min_count=1,
  3276. compact="simplelicensing_licenseText",
  3277. )
  3278. # A canonical, unique, immutable identifier
  3279. @register("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifier", compact_type="software_ContentIdentifier", abstract=False)
  3280. class software_ContentIdentifier(IntegrityMethod):
  3281. NODE_KIND = NodeKind.BlankNodeOrIRI
  3282. NAMED_INDIVIDUALS = {
  3283. }
  3284. @classmethod
  3285. def _register_props(cls):
  3286. super()._register_props()
  3287. # Specifies the type of the content identifier.
  3288. cls._add_property(
  3289. "software_contentIdentifierType",
  3290. EnumProp([
  3291. ("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/gitoid", "gitoid"),
  3292. ("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/swhid", "swhid"),
  3293. ]),
  3294. iri="https://spdx.org/rdf/3.0.1/terms/Software/contentIdentifierType",
  3295. min_count=1,
  3296. compact="software_contentIdentifierType",
  3297. )
  3298. # Specifies the value of the content identifier.
  3299. cls._add_property(
  3300. "software_contentIdentifierValue",
  3301. AnyURIProp(),
  3302. iri="https://spdx.org/rdf/3.0.1/terms/Software/contentIdentifierValue",
  3303. min_count=1,
  3304. compact="software_contentIdentifierValue",
  3305. )
  3306. # Specifies the type of a content identifier.
  3307. @register("https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType", compact_type="software_ContentIdentifierType", abstract=False)
  3308. class software_ContentIdentifierType(SHACLObject):
  3309. NODE_KIND = NodeKind.BlankNodeOrIRI
  3310. NAMED_INDIVIDUALS = {
  3311. "gitoid": "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/gitoid",
  3312. "swhid": "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/swhid",
  3313. }
  3314. # [Gitoid](https://www.iana.org/assignments/uri-schemes/prov/gitoid), stands for [Git Object ID](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects). A gitoid of type blob is a unique hash of a binary artifact. A gitoid may represent either an [Artifact Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-identifier-types) for the software artifact or an [Input Manifest Identifier](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#input-manifest-identifier) for the software artifact's associated [Artifact Input Manifest](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-input-manifest); this ambiguity exists because the Artifact Input Manifest is itself an artifact, and the gitoid of that artifact is its valid identifier. Gitoids calculated on software artifacts (Snippet, File, or Package Elements) should be recorded in the SPDX 3.0 SoftwareArtifact's contentIdentifier property. Gitoids calculated on the Artifact Input Manifest (Input Manifest Identifier) should be recorded in the SPDX 3.0 Element's externalIdentifier property. See [OmniBOR Specification](https://github.com/omnibor/spec/), a minimalistic specification for describing software [Artifact Dependency Graphs](https://github.com/omnibor/spec/blob/eb1ee5c961c16215eb8709b2975d193a2007a35d/spec/SPEC.md#artifact-dependency-graph-adg).
  3315. gitoid = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/gitoid"
  3316. # SoftWare Hash IDentifier, a persistent intrinsic identifier for digital artifacts, such as files, trees (also known as directories or folders), commits, and other objects typically found in version control systems. The format of the identifiers is defined in the [SWHID specification](https://www.swhid.org/specification/v1.1/4.Syntax) (ISO/IEC DIS 18670). They typically look like `swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2`.
  3317. swhid = "https://spdx.org/rdf/3.0.1/terms/Software/ContentIdentifierType/swhid"
  3318. # Enumeration of the different kinds of SPDX file.
  3319. @register("https://spdx.org/rdf/3.0.1/terms/Software/FileKindType", compact_type="software_FileKindType", abstract=False)
  3320. class software_FileKindType(SHACLObject):
  3321. NODE_KIND = NodeKind.BlankNodeOrIRI
  3322. NAMED_INDIVIDUALS = {
  3323. "directory": "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/directory",
  3324. "file": "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/file",
  3325. }
  3326. # The file represents a directory and all content stored in that directory.
  3327. directory = "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/directory"
  3328. # The file represents a single file (default).
  3329. file = "https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/file"
  3330. # Provides a set of values to be used to describe the common types of SBOMs that
  3331. # tools may create.
  3332. @register("https://spdx.org/rdf/3.0.1/terms/Software/SbomType", compact_type="software_SbomType", abstract=False)
  3333. class software_SbomType(SHACLObject):
  3334. NODE_KIND = NodeKind.BlankNodeOrIRI
  3335. NAMED_INDIVIDUALS = {
  3336. "analyzed": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/analyzed",
  3337. "build": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/build",
  3338. "deployed": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/deployed",
  3339. "design": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/design",
  3340. "runtime": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/runtime",
  3341. "source": "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/source",
  3342. }
  3343. # SBOM generated through analysis of artifacts (e.g., executables, packages, containers, and virtual machine images) after its build. Such analysis generally requires a variety of heuristics. In some contexts, this may also be referred to as a "3rd party" SBOM.
  3344. analyzed = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/analyzed"
  3345. # SBOM generated as part of the process of building the software to create a releasable artifact (e.g., executable or package) from data such as source files, dependencies, built components, build process ephemeral data, and other SBOMs.
  3346. build = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/build"
  3347. # SBOM provides an inventory of software that is present on a system. This may be an assembly of other SBOMs that combines analysis of configuration options, and examination of execution behavior in a (potentially simulated) deployment environment.
  3348. deployed = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/deployed"
  3349. # SBOM of intended, planned software project or product with included components (some of which may not yet exist) for a new software artifact.
  3350. design = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/design"
  3351. # SBOM generated through instrumenting the system running the software, to capture only components present in the system, as well as external call-outs or dynamically loaded components. In some contexts, this may also be referred to as an "Instrumented" or "Dynamic" SBOM.
  3352. runtime = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/runtime"
  3353. # SBOM created directly from the development environment, source files, and included dependencies used to build an product artifact.
  3354. source = "https://spdx.org/rdf/3.0.1/terms/Software/SbomType/source"
  3355. # Provides information about the primary purpose of an Element.
  3356. @register("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose", compact_type="software_SoftwarePurpose", abstract=False)
  3357. class software_SoftwarePurpose(SHACLObject):
  3358. NODE_KIND = NodeKind.BlankNodeOrIRI
  3359. NAMED_INDIVIDUALS = {
  3360. "application": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application",
  3361. "archive": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive",
  3362. "bom": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom",
  3363. "configuration": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/configuration",
  3364. "container": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/container",
  3365. "data": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/data",
  3366. "device": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/device",
  3367. "deviceDriver": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/deviceDriver",
  3368. "diskImage": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/diskImage",
  3369. "documentation": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/documentation",
  3370. "evidence": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/evidence",
  3371. "executable": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/executable",
  3372. "file": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/file",
  3373. "filesystemImage": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/filesystemImage",
  3374. "firmware": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/firmware",
  3375. "framework": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/framework",
  3376. "install": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/install",
  3377. "library": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/library",
  3378. "manifest": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/manifest",
  3379. "model": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/model",
  3380. "module": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/module",
  3381. "operatingSystem": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/operatingSystem",
  3382. "other": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/other",
  3383. "patch": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/patch",
  3384. "platform": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/platform",
  3385. "requirement": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/requirement",
  3386. "source": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source",
  3387. "specification": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification",
  3388. "test": "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test",
  3389. }
  3390. # The Element is a software application.
  3391. application = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application"
  3392. # The Element is an archived collection of one or more files (.tar, .zip, etc.).
  3393. archive = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive"
  3394. # The Element is a bill of materials.
  3395. bom = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom"
  3396. # The Element is configuration data.
  3397. configuration = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/configuration"
  3398. # The Element is a container image which can be used by a container runtime application.
  3399. container = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/container"
  3400. # The Element is data.
  3401. data = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/data"
  3402. # The Element refers to a chipset, processor, or electronic board.
  3403. device = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/device"
  3404. # The Element represents software that controls hardware devices.
  3405. deviceDriver = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/deviceDriver"
  3406. # The Element refers to a disk image that can be written to a disk, booted in a VM, etc. A disk image typically contains most or all of the components necessary to boot, such as bootloaders, kernels, firmware, userspace, etc.
  3407. diskImage = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/diskImage"
  3408. # The Element is documentation.
  3409. documentation = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/documentation"
  3410. # The Element is the evidence that a specification or requirement has been fulfilled.
  3411. evidence = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/evidence"
  3412. # The Element is an Artifact that can be run on a computer.
  3413. executable = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/executable"
  3414. # The Element is a single file which can be independently distributed (configuration file, statically linked binary, Kubernetes deployment, etc.).
  3415. file = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/file"
  3416. # The Element is a file system image that can be written to a disk (or virtual) partition.
  3417. filesystemImage = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/filesystemImage"
  3418. # The Element provides low level control over a device's hardware.
  3419. firmware = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/firmware"
  3420. # The Element is a software framework.
  3421. framework = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/framework"
  3422. # The Element is used to install software on disk.
  3423. install = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/install"
  3424. # The Element is a software library.
  3425. library = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/library"
  3426. # The Element is a software manifest.
  3427. manifest = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/manifest"
  3428. # The Element is a machine learning or artificial intelligence model.
  3429. model = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/model"
  3430. # The Element is a module of a piece of software.
  3431. module = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/module"
  3432. # The Element is an operating system.
  3433. operatingSystem = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/operatingSystem"
  3434. # The Element doesn't fit into any of the other categories.
  3435. other = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/other"
  3436. # The Element contains a set of changes to update, fix, or improve another Element.
  3437. patch = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/patch"
  3438. # The Element represents a runtime environment.
  3439. platform = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/platform"
  3440. # The Element provides a requirement needed as input for another Element.
  3441. requirement = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/requirement"
  3442. # The Element is a single or a collection of source files.
  3443. source = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source"
  3444. # The Element is a plan, guideline or strategy how to create, perform or analyze an application.
  3445. specification = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification"
  3446. # The Element is a test used to verify functionality on an software element.
  3447. test = "https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test"
  3448. # Class that describes a build instance of software/artifacts.
  3449. @register("https://spdx.org/rdf/3.0.1/terms/Build/Build", compact_type="build_Build", abstract=False)
  3450. class build_Build(Element):
  3451. NODE_KIND = NodeKind.IRI
  3452. ID_ALIAS = "spdxId"
  3453. NAMED_INDIVIDUALS = {
  3454. }
  3455. @classmethod
  3456. def _register_props(cls):
  3457. super()._register_props()
  3458. # Property that describes the time at which a build stops.
  3459. cls._add_property(
  3460. "build_buildEndTime",
  3461. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3462. iri="https://spdx.org/rdf/3.0.1/terms/Build/buildEndTime",
  3463. compact="build_buildEndTime",
  3464. )
  3465. # A buildId is a locally unique identifier used by a builder to identify a unique
  3466. # instance of a build produced by it.
  3467. cls._add_property(
  3468. "build_buildId",
  3469. StringProp(),
  3470. iri="https://spdx.org/rdf/3.0.1/terms/Build/buildId",
  3471. compact="build_buildId",
  3472. )
  3473. # Property describing the start time of a build.
  3474. cls._add_property(
  3475. "build_buildStartTime",
  3476. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3477. iri="https://spdx.org/rdf/3.0.1/terms/Build/buildStartTime",
  3478. compact="build_buildStartTime",
  3479. )
  3480. # A buildType is a hint that is used to indicate the toolchain, platform, or
  3481. # infrastructure that the build was invoked on.
  3482. cls._add_property(
  3483. "build_buildType",
  3484. AnyURIProp(),
  3485. iri="https://spdx.org/rdf/3.0.1/terms/Build/buildType",
  3486. min_count=1,
  3487. compact="build_buildType",
  3488. )
  3489. # Property that describes the digest of the build configuration file used to
  3490. # invoke a build.
  3491. cls._add_property(
  3492. "build_configSourceDigest",
  3493. ListProp(ObjectProp(Hash, False)),
  3494. iri="https://spdx.org/rdf/3.0.1/terms/Build/configSourceDigest",
  3495. compact="build_configSourceDigest",
  3496. )
  3497. # Property describes the invocation entrypoint of a build.
  3498. cls._add_property(
  3499. "build_configSourceEntrypoint",
  3500. ListProp(StringProp()),
  3501. iri="https://spdx.org/rdf/3.0.1/terms/Build/configSourceEntrypoint",
  3502. compact="build_configSourceEntrypoint",
  3503. )
  3504. # Property that describes the URI of the build configuration source file.
  3505. cls._add_property(
  3506. "build_configSourceUri",
  3507. ListProp(AnyURIProp()),
  3508. iri="https://spdx.org/rdf/3.0.1/terms/Build/configSourceUri",
  3509. compact="build_configSourceUri",
  3510. )
  3511. # Property describing the session in which a build is invoked.
  3512. cls._add_property(
  3513. "build_environment",
  3514. ListProp(ObjectProp(DictionaryEntry, False)),
  3515. iri="https://spdx.org/rdf/3.0.1/terms/Build/environment",
  3516. compact="build_environment",
  3517. )
  3518. # Property describing a parameter used in an instance of a build.
  3519. cls._add_property(
  3520. "build_parameter",
  3521. ListProp(ObjectProp(DictionaryEntry, False)),
  3522. iri="https://spdx.org/rdf/3.0.1/terms/Build/parameter",
  3523. compact="build_parameter",
  3524. )
  3525. # Agent represents anything with the potential to act on a system.
  3526. @register("https://spdx.org/rdf/3.0.1/terms/Core/Agent", compact_type="Agent", abstract=False)
  3527. class Agent(Element):
  3528. NODE_KIND = NodeKind.IRI
  3529. ID_ALIAS = "spdxId"
  3530. NAMED_INDIVIDUALS = {
  3531. }
  3532. # An assertion made in relation to one or more elements.
  3533. @register("https://spdx.org/rdf/3.0.1/terms/Core/Annotation", compact_type="Annotation", abstract=False)
  3534. class Annotation(Element):
  3535. NODE_KIND = NodeKind.IRI
  3536. ID_ALIAS = "spdxId"
  3537. NAMED_INDIVIDUALS = {
  3538. }
  3539. @classmethod
  3540. def _register_props(cls):
  3541. super()._register_props()
  3542. # Describes the type of annotation.
  3543. cls._add_property(
  3544. "annotationType",
  3545. EnumProp([
  3546. ("https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/other", "other"),
  3547. ("https://spdx.org/rdf/3.0.1/terms/Core/AnnotationType/review", "review"),
  3548. ]),
  3549. iri="https://spdx.org/rdf/3.0.1/terms/Core/annotationType",
  3550. min_count=1,
  3551. compact="annotationType",
  3552. )
  3553. # Provides information about the content type of an Element or a Property.
  3554. cls._add_property(
  3555. "contentType",
  3556. StringProp(pattern=r"^[^\/]+\/[^\/]+$",),
  3557. iri="https://spdx.org/rdf/3.0.1/terms/Core/contentType",
  3558. compact="contentType",
  3559. )
  3560. # Commentary on an assertion that an annotator has made.
  3561. cls._add_property(
  3562. "statement",
  3563. StringProp(),
  3564. iri="https://spdx.org/rdf/3.0.1/terms/Core/statement",
  3565. compact="statement",
  3566. )
  3567. # An Element an annotator has made an assertion about.
  3568. cls._add_property(
  3569. "subject",
  3570. ObjectProp(Element, True, context=[
  3571. ("https://spdx.org/rdf/3.0.1/terms/Core/NoneElement", "NoneElement"),
  3572. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  3573. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  3574. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  3575. ("https://spdx.org/rdf/3.0.1/terms/Core/NoAssertionElement", "NoAssertionElement"),
  3576. ],),
  3577. iri="https://spdx.org/rdf/3.0.1/terms/Core/subject",
  3578. min_count=1,
  3579. compact="subject",
  3580. )
  3581. # A distinct article or unit within the digital domain.
  3582. @register("https://spdx.org/rdf/3.0.1/terms/Core/Artifact", compact_type="Artifact", abstract=True)
  3583. class Artifact(Element):
  3584. NODE_KIND = NodeKind.IRI
  3585. ID_ALIAS = "spdxId"
  3586. NAMED_INDIVIDUALS = {
  3587. }
  3588. @classmethod
  3589. def _register_props(cls):
  3590. super()._register_props()
  3591. # Specifies the time an artifact was built.
  3592. cls._add_property(
  3593. "builtTime",
  3594. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3595. iri="https://spdx.org/rdf/3.0.1/terms/Core/builtTime",
  3596. compact="builtTime",
  3597. )
  3598. # Identifies from where or whom the Element originally came.
  3599. cls._add_property(
  3600. "originatedBy",
  3601. ListProp(ObjectProp(Agent, False, context=[
  3602. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  3603. ],)),
  3604. iri="https://spdx.org/rdf/3.0.1/terms/Core/originatedBy",
  3605. compact="originatedBy",
  3606. )
  3607. # Specifies the time an artifact was released.
  3608. cls._add_property(
  3609. "releaseTime",
  3610. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3611. iri="https://spdx.org/rdf/3.0.1/terms/Core/releaseTime",
  3612. compact="releaseTime",
  3613. )
  3614. # The name of a relevant standard that may apply to an artifact.
  3615. cls._add_property(
  3616. "standardName",
  3617. ListProp(StringProp()),
  3618. iri="https://spdx.org/rdf/3.0.1/terms/Core/standardName",
  3619. compact="standardName",
  3620. )
  3621. # Identifies who or what supplied the artifact or VulnAssessmentRelationship
  3622. # referenced by the Element.
  3623. cls._add_property(
  3624. "suppliedBy",
  3625. ObjectProp(Agent, False, context=[
  3626. ("https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization", "SpdxOrganization"),
  3627. ],),
  3628. iri="https://spdx.org/rdf/3.0.1/terms/Core/suppliedBy",
  3629. compact="suppliedBy",
  3630. )
  3631. # Specifies the level of support associated with an artifact.
  3632. cls._add_property(
  3633. "supportLevel",
  3634. ListProp(EnumProp([
  3635. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/deployed", "deployed"),
  3636. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/development", "development"),
  3637. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/endOfSupport", "endOfSupport"),
  3638. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/limitedSupport", "limitedSupport"),
  3639. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noAssertion", "noAssertion"),
  3640. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/noSupport", "noSupport"),
  3641. ("https://spdx.org/rdf/3.0.1/terms/Core/SupportType/support", "support"),
  3642. ])),
  3643. iri="https://spdx.org/rdf/3.0.1/terms/Core/supportLevel",
  3644. compact="supportLevel",
  3645. )
  3646. # Specifies until when the artifact can be used before its usage needs to be
  3647. # reassessed.
  3648. cls._add_property(
  3649. "validUntilTime",
  3650. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  3651. iri="https://spdx.org/rdf/3.0.1/terms/Core/validUntilTime",
  3652. compact="validUntilTime",
  3653. )
  3654. # A collection of Elements that have a shared context.
  3655. @register("https://spdx.org/rdf/3.0.1/terms/Core/Bundle", compact_type="Bundle", abstract=False)
  3656. class Bundle(ElementCollection):
  3657. NODE_KIND = NodeKind.IRI
  3658. ID_ALIAS = "spdxId"
  3659. NAMED_INDIVIDUALS = {
  3660. }
  3661. @classmethod
  3662. def _register_props(cls):
  3663. super()._register_props()
  3664. # Gives information about the circumstances or unifying properties
  3665. # that Elements of the bundle have been assembled under.
  3666. cls._add_property(
  3667. "context",
  3668. StringProp(),
  3669. iri="https://spdx.org/rdf/3.0.1/terms/Core/context",
  3670. compact="context",
  3671. )
  3672. # A mathematically calculated representation of a grouping of data.
  3673. @register("https://spdx.org/rdf/3.0.1/terms/Core/Hash", compact_type="Hash", abstract=False)
  3674. class Hash(IntegrityMethod):
  3675. NODE_KIND = NodeKind.BlankNodeOrIRI
  3676. NAMED_INDIVIDUALS = {
  3677. }
  3678. @classmethod
  3679. def _register_props(cls):
  3680. super()._register_props()
  3681. # Specifies the algorithm used for calculating the hash value.
  3682. cls._add_property(
  3683. "algorithm",
  3684. EnumProp([
  3685. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/adler32", "adler32"),
  3686. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b256", "blake2b256"),
  3687. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b384", "blake2b384"),
  3688. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake2b512", "blake2b512"),
  3689. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/blake3", "blake3"),
  3690. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsDilithium", "crystalsDilithium"),
  3691. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/crystalsKyber", "crystalsKyber"),
  3692. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/falcon", "falcon"),
  3693. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md2", "md2"),
  3694. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md4", "md4"),
  3695. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md5", "md5"),
  3696. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/md6", "md6"),
  3697. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/other", "other"),
  3698. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha1", "sha1"),
  3699. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha224", "sha224"),
  3700. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha256", "sha256"),
  3701. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha384", "sha384"),
  3702. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_224", "sha3_224"),
  3703. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_256", "sha3_256"),
  3704. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_384", "sha3_384"),
  3705. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha3_512", "sha3_512"),
  3706. ("https://spdx.org/rdf/3.0.1/terms/Core/HashAlgorithm/sha512", "sha512"),
  3707. ]),
  3708. iri="https://spdx.org/rdf/3.0.1/terms/Core/algorithm",
  3709. min_count=1,
  3710. compact="algorithm",
  3711. )
  3712. # The result of applying a hash algorithm to an Element.
  3713. cls._add_property(
  3714. "hashValue",
  3715. StringProp(),
  3716. iri="https://spdx.org/rdf/3.0.1/terms/Core/hashValue",
  3717. min_count=1,
  3718. compact="hashValue",
  3719. )
  3720. # Provide context for a relationship that occurs in the lifecycle.
  3721. @register("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopedRelationship", compact_type="LifecycleScopedRelationship", abstract=False)
  3722. class LifecycleScopedRelationship(Relationship):
  3723. NODE_KIND = NodeKind.IRI
  3724. ID_ALIAS = "spdxId"
  3725. NAMED_INDIVIDUALS = {
  3726. }
  3727. @classmethod
  3728. def _register_props(cls):
  3729. super()._register_props()
  3730. # Capture the scope of information about a specific relationship between elements.
  3731. cls._add_property(
  3732. "scope",
  3733. EnumProp([
  3734. ("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/build", "build"),
  3735. ("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/design", "design"),
  3736. ("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/development", "development"),
  3737. ("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/other", "other"),
  3738. ("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/runtime", "runtime"),
  3739. ("https://spdx.org/rdf/3.0.1/terms/Core/LifecycleScopeType/test", "test"),
  3740. ]),
  3741. iri="https://spdx.org/rdf/3.0.1/terms/Core/scope",
  3742. compact="scope",
  3743. )
  3744. # A group of people who work together in an organized way for a shared purpose.
  3745. @register("https://spdx.org/rdf/3.0.1/terms/Core/Organization", compact_type="Organization", abstract=False)
  3746. class Organization(Agent):
  3747. NODE_KIND = NodeKind.IRI
  3748. ID_ALIAS = "spdxId"
  3749. NAMED_INDIVIDUALS = {
  3750. "SpdxOrganization": "https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization",
  3751. }
  3752. # An Organization representing the SPDX Project.
  3753. SpdxOrganization = "https://spdx.org/rdf/3.0.1/terms/Core/SpdxOrganization"
  3754. # An individual human being.
  3755. @register("https://spdx.org/rdf/3.0.1/terms/Core/Person", compact_type="Person", abstract=False)
  3756. class Person(Agent):
  3757. NODE_KIND = NodeKind.IRI
  3758. ID_ALIAS = "spdxId"
  3759. NAMED_INDIVIDUALS = {
  3760. }
  3761. # A software agent.
  3762. @register("https://spdx.org/rdf/3.0.1/terms/Core/SoftwareAgent", compact_type="SoftwareAgent", abstract=False)
  3763. class SoftwareAgent(Agent):
  3764. NODE_KIND = NodeKind.IRI
  3765. ID_ALIAS = "spdxId"
  3766. NAMED_INDIVIDUALS = {
  3767. }
  3768. # Portion of an AnyLicenseInfo representing a set of licensing information
  3769. # where all elements apply.
  3770. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ConjunctiveLicenseSet", compact_type="expandedlicensing_ConjunctiveLicenseSet", abstract=False)
  3771. class expandedlicensing_ConjunctiveLicenseSet(simplelicensing_AnyLicenseInfo):
  3772. NODE_KIND = NodeKind.IRI
  3773. ID_ALIAS = "spdxId"
  3774. NAMED_INDIVIDUALS = {
  3775. }
  3776. @classmethod
  3777. def _register_props(cls):
  3778. super()._register_props()
  3779. # A license expression participating in a license set.
  3780. cls._add_property(
  3781. "expandedlicensing_member",
  3782. ListProp(ObjectProp(simplelicensing_AnyLicenseInfo, False, context=[
  3783. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  3784. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  3785. ],)),
  3786. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/member",
  3787. min_count=2,
  3788. compact="expandedlicensing_member",
  3789. )
  3790. # A license addition that is not listed on the SPDX Exceptions List.
  3791. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicenseAddition", compact_type="expandedlicensing_CustomLicenseAddition", abstract=False)
  3792. class expandedlicensing_CustomLicenseAddition(expandedlicensing_LicenseAddition):
  3793. NODE_KIND = NodeKind.IRI
  3794. ID_ALIAS = "spdxId"
  3795. NAMED_INDIVIDUALS = {
  3796. }
  3797. # Portion of an AnyLicenseInfo representing a set of licensing information where
  3798. # only one of the elements applies.
  3799. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/DisjunctiveLicenseSet", compact_type="expandedlicensing_DisjunctiveLicenseSet", abstract=False)
  3800. class expandedlicensing_DisjunctiveLicenseSet(simplelicensing_AnyLicenseInfo):
  3801. NODE_KIND = NodeKind.IRI
  3802. ID_ALIAS = "spdxId"
  3803. NAMED_INDIVIDUALS = {
  3804. }
  3805. @classmethod
  3806. def _register_props(cls):
  3807. super()._register_props()
  3808. # A license expression participating in a license set.
  3809. cls._add_property(
  3810. "expandedlicensing_member",
  3811. ListProp(ObjectProp(simplelicensing_AnyLicenseInfo, False, context=[
  3812. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense", "expandedlicensing_NoAssertionLicense"),
  3813. ("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense", "expandedlicensing_NoneLicense"),
  3814. ],)),
  3815. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/member",
  3816. min_count=2,
  3817. compact="expandedlicensing_member",
  3818. )
  3819. # Abstract class representing a License or an OrLaterOperator.
  3820. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ExtendableLicense", compact_type="expandedlicensing_ExtendableLicense", abstract=True)
  3821. class expandedlicensing_ExtendableLicense(simplelicensing_AnyLicenseInfo):
  3822. NODE_KIND = NodeKind.IRI
  3823. ID_ALIAS = "spdxId"
  3824. NAMED_INDIVIDUALS = {
  3825. }
  3826. # A concrete subclass of AnyLicenseInfo used by Individuals in the
  3827. # ExpandedLicensing profile.
  3828. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/IndividualLicensingInfo", compact_type="expandedlicensing_IndividualLicensingInfo", abstract=False)
  3829. class expandedlicensing_IndividualLicensingInfo(simplelicensing_AnyLicenseInfo):
  3830. NODE_KIND = NodeKind.IRI
  3831. ID_ALIAS = "spdxId"
  3832. NAMED_INDIVIDUALS = {
  3833. "NoAssertionLicense": "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense",
  3834. "NoneLicense": "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense",
  3835. }
  3836. # An Individual Value for License when no assertion can be made about its actual
  3837. # value.
  3838. NoAssertionLicense = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoAssertionLicense"
  3839. # An Individual Value for License where the SPDX data creator determines that no
  3840. # license is present.
  3841. NoneLicense = "https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/NoneLicense"
  3842. # Abstract class for the portion of an AnyLicenseInfo representing a license.
  3843. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/License", compact_type="expandedlicensing_License", abstract=True)
  3844. class expandedlicensing_License(expandedlicensing_ExtendableLicense):
  3845. NODE_KIND = NodeKind.IRI
  3846. ID_ALIAS = "spdxId"
  3847. NAMED_INDIVIDUALS = {
  3848. }
  3849. @classmethod
  3850. def _register_props(cls):
  3851. super()._register_props()
  3852. # Specifies whether a license or additional text identifier has been marked as
  3853. # deprecated.
  3854. cls._add_property(
  3855. "expandedlicensing_isDeprecatedLicenseId",
  3856. BooleanProp(),
  3857. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isDeprecatedLicenseId",
  3858. compact="expandedlicensing_isDeprecatedLicenseId",
  3859. )
  3860. # Specifies whether the License is listed as free by the
  3861. # Free Software Foundation (FSF).
  3862. cls._add_property(
  3863. "expandedlicensing_isFsfLibre",
  3864. BooleanProp(),
  3865. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isFsfLibre",
  3866. compact="expandedlicensing_isFsfLibre",
  3867. )
  3868. # Specifies whether the License is listed as approved by the
  3869. # Open Source Initiative (OSI).
  3870. cls._add_property(
  3871. "expandedlicensing_isOsiApproved",
  3872. BooleanProp(),
  3873. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/isOsiApproved",
  3874. compact="expandedlicensing_isOsiApproved",
  3875. )
  3876. # Identifies all the text and metadata associated with a license in the license
  3877. # XML format.
  3878. cls._add_property(
  3879. "expandedlicensing_licenseXml",
  3880. StringProp(),
  3881. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/licenseXml",
  3882. compact="expandedlicensing_licenseXml",
  3883. )
  3884. # Specifies the licenseId that is preferred to be used in place of a deprecated
  3885. # License or LicenseAddition.
  3886. cls._add_property(
  3887. "expandedlicensing_obsoletedBy",
  3888. StringProp(),
  3889. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/obsoletedBy",
  3890. compact="expandedlicensing_obsoletedBy",
  3891. )
  3892. # Contains a URL where the License or LicenseAddition can be found in use.
  3893. cls._add_property(
  3894. "expandedlicensing_seeAlso",
  3895. ListProp(AnyURIProp()),
  3896. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/seeAlso",
  3897. compact="expandedlicensing_seeAlso",
  3898. )
  3899. # Provides a License author's preferred text to indicate that a file is covered
  3900. # by the License.
  3901. cls._add_property(
  3902. "expandedlicensing_standardLicenseHeader",
  3903. StringProp(),
  3904. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/standardLicenseHeader",
  3905. compact="expandedlicensing_standardLicenseHeader",
  3906. )
  3907. # Identifies the full text of a License, in SPDX templating format.
  3908. cls._add_property(
  3909. "expandedlicensing_standardLicenseTemplate",
  3910. StringProp(),
  3911. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/standardLicenseTemplate",
  3912. compact="expandedlicensing_standardLicenseTemplate",
  3913. )
  3914. # Identifies the full text of a License or Addition.
  3915. cls._add_property(
  3916. "simplelicensing_licenseText",
  3917. StringProp(),
  3918. iri="https://spdx.org/rdf/3.0.1/terms/SimpleLicensing/licenseText",
  3919. min_count=1,
  3920. compact="simplelicensing_licenseText",
  3921. )
  3922. # A license that is listed on the SPDX License List.
  3923. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/ListedLicense", compact_type="expandedlicensing_ListedLicense", abstract=False)
  3924. class expandedlicensing_ListedLicense(expandedlicensing_License):
  3925. NODE_KIND = NodeKind.IRI
  3926. ID_ALIAS = "spdxId"
  3927. NAMED_INDIVIDUALS = {
  3928. }
  3929. @classmethod
  3930. def _register_props(cls):
  3931. super()._register_props()
  3932. # Specifies the SPDX License List version in which this license or exception
  3933. # identifier was deprecated.
  3934. cls._add_property(
  3935. "expandedlicensing_deprecatedVersion",
  3936. StringProp(),
  3937. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/deprecatedVersion",
  3938. compact="expandedlicensing_deprecatedVersion",
  3939. )
  3940. # Specifies the SPDX License List version in which this ListedLicense or
  3941. # ListedLicenseException identifier was first added.
  3942. cls._add_property(
  3943. "expandedlicensing_listVersionAdded",
  3944. StringProp(),
  3945. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/listVersionAdded",
  3946. compact="expandedlicensing_listVersionAdded",
  3947. )
  3948. # Portion of an AnyLicenseInfo representing this version, or any later version,
  3949. # of the indicated License.
  3950. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/OrLaterOperator", compact_type="expandedlicensing_OrLaterOperator", abstract=False)
  3951. class expandedlicensing_OrLaterOperator(expandedlicensing_ExtendableLicense):
  3952. NODE_KIND = NodeKind.IRI
  3953. ID_ALIAS = "spdxId"
  3954. NAMED_INDIVIDUALS = {
  3955. }
  3956. @classmethod
  3957. def _register_props(cls):
  3958. super()._register_props()
  3959. # A License participating in an 'or later' model.
  3960. cls._add_property(
  3961. "expandedlicensing_subjectLicense",
  3962. ObjectProp(expandedlicensing_License, True),
  3963. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/subjectLicense",
  3964. min_count=1,
  3965. compact="expandedlicensing_subjectLicense",
  3966. )
  3967. # Portion of an AnyLicenseInfo representing a License which has additional
  3968. # text applied to it.
  3969. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/WithAdditionOperator", compact_type="expandedlicensing_WithAdditionOperator", abstract=False)
  3970. class expandedlicensing_WithAdditionOperator(simplelicensing_AnyLicenseInfo):
  3971. NODE_KIND = NodeKind.IRI
  3972. ID_ALIAS = "spdxId"
  3973. NAMED_INDIVIDUALS = {
  3974. }
  3975. @classmethod
  3976. def _register_props(cls):
  3977. super()._register_props()
  3978. # A LicenseAddition participating in a 'with addition' model.
  3979. cls._add_property(
  3980. "expandedlicensing_subjectAddition",
  3981. ObjectProp(expandedlicensing_LicenseAddition, True),
  3982. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/subjectAddition",
  3983. min_count=1,
  3984. compact="expandedlicensing_subjectAddition",
  3985. )
  3986. # A License participating in a 'with addition' model.
  3987. cls._add_property(
  3988. "expandedlicensing_subjectExtendableLicense",
  3989. ObjectProp(expandedlicensing_ExtendableLicense, True),
  3990. iri="https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/subjectExtendableLicense",
  3991. min_count=1,
  3992. compact="expandedlicensing_subjectExtendableLicense",
  3993. )
  3994. # A type of extension consisting of a list of name value pairs.
  3995. @register("https://spdx.org/rdf/3.0.1/terms/Extension/CdxPropertiesExtension", compact_type="extension_CdxPropertiesExtension", abstract=False)
  3996. class extension_CdxPropertiesExtension(extension_Extension):
  3997. NODE_KIND = NodeKind.BlankNodeOrIRI
  3998. NAMED_INDIVIDUALS = {
  3999. }
  4000. @classmethod
  4001. def _register_props(cls):
  4002. super()._register_props()
  4003. # Provides a map of a property names to a values.
  4004. cls._add_property(
  4005. "extension_cdxProperty",
  4006. ListProp(ObjectProp(extension_CdxPropertyEntry, False)),
  4007. iri="https://spdx.org/rdf/3.0.1/terms/Extension/cdxProperty",
  4008. min_count=1,
  4009. compact="extension_cdxProperty",
  4010. )
  4011. # Provides a CVSS version 2.0 assessment for a vulnerability.
  4012. @register("https://spdx.org/rdf/3.0.1/terms/Security/CvssV2VulnAssessmentRelationship", compact_type="security_CvssV2VulnAssessmentRelationship", abstract=False)
  4013. class security_CvssV2VulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4014. NODE_KIND = NodeKind.IRI
  4015. ID_ALIAS = "spdxId"
  4016. NAMED_INDIVIDUALS = {
  4017. }
  4018. @classmethod
  4019. def _register_props(cls):
  4020. super()._register_props()
  4021. # Provides a numerical (0-10) representation of the severity of a vulnerability.
  4022. cls._add_property(
  4023. "security_score",
  4024. FloatProp(),
  4025. iri="https://spdx.org/rdf/3.0.1/terms/Security/score",
  4026. min_count=1,
  4027. compact="security_score",
  4028. )
  4029. # Specifies the CVSS vector string for a vulnerability.
  4030. cls._add_property(
  4031. "security_vectorString",
  4032. StringProp(),
  4033. iri="https://spdx.org/rdf/3.0.1/terms/Security/vectorString",
  4034. min_count=1,
  4035. compact="security_vectorString",
  4036. )
  4037. # Provides a CVSS version 3 assessment for a vulnerability.
  4038. @register("https://spdx.org/rdf/3.0.1/terms/Security/CvssV3VulnAssessmentRelationship", compact_type="security_CvssV3VulnAssessmentRelationship", abstract=False)
  4039. class security_CvssV3VulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4040. NODE_KIND = NodeKind.IRI
  4041. ID_ALIAS = "spdxId"
  4042. NAMED_INDIVIDUALS = {
  4043. }
  4044. @classmethod
  4045. def _register_props(cls):
  4046. super()._register_props()
  4047. # Provides a numerical (0-10) representation of the severity of a vulnerability.
  4048. cls._add_property(
  4049. "security_score",
  4050. FloatProp(),
  4051. iri="https://spdx.org/rdf/3.0.1/terms/Security/score",
  4052. min_count=1,
  4053. compact="security_score",
  4054. )
  4055. # Specifies the CVSS qualitative severity rating of a vulnerability in relation to a piece of software.
  4056. cls._add_property(
  4057. "security_severity",
  4058. EnumProp([
  4059. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical", "critical"),
  4060. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high", "high"),
  4061. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low", "low"),
  4062. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium", "medium"),
  4063. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none", "none"),
  4064. ]),
  4065. iri="https://spdx.org/rdf/3.0.1/terms/Security/severity",
  4066. min_count=1,
  4067. compact="security_severity",
  4068. )
  4069. # Specifies the CVSS vector string for a vulnerability.
  4070. cls._add_property(
  4071. "security_vectorString",
  4072. StringProp(),
  4073. iri="https://spdx.org/rdf/3.0.1/terms/Security/vectorString",
  4074. min_count=1,
  4075. compact="security_vectorString",
  4076. )
  4077. # Provides a CVSS version 4 assessment for a vulnerability.
  4078. @register("https://spdx.org/rdf/3.0.1/terms/Security/CvssV4VulnAssessmentRelationship", compact_type="security_CvssV4VulnAssessmentRelationship", abstract=False)
  4079. class security_CvssV4VulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4080. NODE_KIND = NodeKind.IRI
  4081. ID_ALIAS = "spdxId"
  4082. NAMED_INDIVIDUALS = {
  4083. }
  4084. @classmethod
  4085. def _register_props(cls):
  4086. super()._register_props()
  4087. # Provides a numerical (0-10) representation of the severity of a vulnerability.
  4088. cls._add_property(
  4089. "security_score",
  4090. FloatProp(),
  4091. iri="https://spdx.org/rdf/3.0.1/terms/Security/score",
  4092. min_count=1,
  4093. compact="security_score",
  4094. )
  4095. # Specifies the CVSS qualitative severity rating of a vulnerability in relation to a piece of software.
  4096. cls._add_property(
  4097. "security_severity",
  4098. EnumProp([
  4099. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/critical", "critical"),
  4100. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/high", "high"),
  4101. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/low", "low"),
  4102. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/medium", "medium"),
  4103. ("https://spdx.org/rdf/3.0.1/terms/Security/CvssSeverityType/none", "none"),
  4104. ]),
  4105. iri="https://spdx.org/rdf/3.0.1/terms/Security/severity",
  4106. min_count=1,
  4107. compact="security_severity",
  4108. )
  4109. # Specifies the CVSS vector string for a vulnerability.
  4110. cls._add_property(
  4111. "security_vectorString",
  4112. StringProp(),
  4113. iri="https://spdx.org/rdf/3.0.1/terms/Security/vectorString",
  4114. min_count=1,
  4115. compact="security_vectorString",
  4116. )
  4117. # Provides an EPSS assessment for a vulnerability.
  4118. @register("https://spdx.org/rdf/3.0.1/terms/Security/EpssVulnAssessmentRelationship", compact_type="security_EpssVulnAssessmentRelationship", abstract=False)
  4119. class security_EpssVulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4120. NODE_KIND = NodeKind.IRI
  4121. ID_ALIAS = "spdxId"
  4122. NAMED_INDIVIDUALS = {
  4123. }
  4124. @classmethod
  4125. def _register_props(cls):
  4126. super()._register_props()
  4127. # The percentile of the current probability score.
  4128. cls._add_property(
  4129. "security_percentile",
  4130. FloatProp(),
  4131. iri="https://spdx.org/rdf/3.0.1/terms/Security/percentile",
  4132. min_count=1,
  4133. compact="security_percentile",
  4134. )
  4135. # A probability score between 0 and 1 of a vulnerability being exploited.
  4136. cls._add_property(
  4137. "security_probability",
  4138. FloatProp(),
  4139. iri="https://spdx.org/rdf/3.0.1/terms/Security/probability",
  4140. min_count=1,
  4141. compact="security_probability",
  4142. )
  4143. # Provides an exploit assessment of a vulnerability.
  4144. @register("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogVulnAssessmentRelationship", compact_type="security_ExploitCatalogVulnAssessmentRelationship", abstract=False)
  4145. class security_ExploitCatalogVulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4146. NODE_KIND = NodeKind.IRI
  4147. ID_ALIAS = "spdxId"
  4148. NAMED_INDIVIDUALS = {
  4149. }
  4150. @classmethod
  4151. def _register_props(cls):
  4152. super()._register_props()
  4153. # Specifies the exploit catalog type.
  4154. cls._add_property(
  4155. "security_catalogType",
  4156. EnumProp([
  4157. ("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/kev", "kev"),
  4158. ("https://spdx.org/rdf/3.0.1/terms/Security/ExploitCatalogType/other", "other"),
  4159. ]),
  4160. iri="https://spdx.org/rdf/3.0.1/terms/Security/catalogType",
  4161. min_count=1,
  4162. compact="security_catalogType",
  4163. )
  4164. # Describe that a CVE is known to have an exploit because it's been listed in an exploit catalog.
  4165. cls._add_property(
  4166. "security_exploited",
  4167. BooleanProp(),
  4168. iri="https://spdx.org/rdf/3.0.1/terms/Security/exploited",
  4169. min_count=1,
  4170. compact="security_exploited",
  4171. )
  4172. # Provides the location of an exploit catalog.
  4173. cls._add_property(
  4174. "security_locator",
  4175. AnyURIProp(),
  4176. iri="https://spdx.org/rdf/3.0.1/terms/Security/locator",
  4177. min_count=1,
  4178. compact="security_locator",
  4179. )
  4180. # Provides an SSVC assessment for a vulnerability.
  4181. @register("https://spdx.org/rdf/3.0.1/terms/Security/SsvcVulnAssessmentRelationship", compact_type="security_SsvcVulnAssessmentRelationship", abstract=False)
  4182. class security_SsvcVulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4183. NODE_KIND = NodeKind.IRI
  4184. ID_ALIAS = "spdxId"
  4185. NAMED_INDIVIDUALS = {
  4186. }
  4187. @classmethod
  4188. def _register_props(cls):
  4189. super()._register_props()
  4190. # Provide the enumeration of possible decisions in the
  4191. # [Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree](https://www.cisa.gov/stakeholder-specific-vulnerability-categorization-ssvc).
  4192. cls._add_property(
  4193. "security_decisionType",
  4194. EnumProp([
  4195. ("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/act", "act"),
  4196. ("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/attend", "attend"),
  4197. ("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/track", "track"),
  4198. ("https://spdx.org/rdf/3.0.1/terms/Security/SsvcDecisionType/trackStar", "trackStar"),
  4199. ]),
  4200. iri="https://spdx.org/rdf/3.0.1/terms/Security/decisionType",
  4201. min_count=1,
  4202. compact="security_decisionType",
  4203. )
  4204. # Abstract ancestor class for all VEX relationships
  4205. @register("https://spdx.org/rdf/3.0.1/terms/Security/VexVulnAssessmentRelationship", compact_type="security_VexVulnAssessmentRelationship", abstract=True)
  4206. class security_VexVulnAssessmentRelationship(security_VulnAssessmentRelationship):
  4207. NODE_KIND = NodeKind.IRI
  4208. ID_ALIAS = "spdxId"
  4209. NAMED_INDIVIDUALS = {
  4210. }
  4211. @classmethod
  4212. def _register_props(cls):
  4213. super()._register_props()
  4214. # Conveys information about how VEX status was determined.
  4215. cls._add_property(
  4216. "security_statusNotes",
  4217. StringProp(),
  4218. iri="https://spdx.org/rdf/3.0.1/terms/Security/statusNotes",
  4219. compact="security_statusNotes",
  4220. )
  4221. # Specifies the version of a VEX statement.
  4222. cls._add_property(
  4223. "security_vexVersion",
  4224. StringProp(),
  4225. iri="https://spdx.org/rdf/3.0.1/terms/Security/vexVersion",
  4226. compact="security_vexVersion",
  4227. )
  4228. # Specifies a vulnerability and its associated information.
  4229. @register("https://spdx.org/rdf/3.0.1/terms/Security/Vulnerability", compact_type="security_Vulnerability", abstract=False)
  4230. class security_Vulnerability(Artifact):
  4231. NODE_KIND = NodeKind.IRI
  4232. ID_ALIAS = "spdxId"
  4233. NAMED_INDIVIDUALS = {
  4234. }
  4235. @classmethod
  4236. def _register_props(cls):
  4237. super()._register_props()
  4238. # Specifies a time when a vulnerability assessment was modified
  4239. cls._add_property(
  4240. "security_modifiedTime",
  4241. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  4242. iri="https://spdx.org/rdf/3.0.1/terms/Security/modifiedTime",
  4243. compact="security_modifiedTime",
  4244. )
  4245. # Specifies the time when a vulnerability was published.
  4246. cls._add_property(
  4247. "security_publishedTime",
  4248. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  4249. iri="https://spdx.org/rdf/3.0.1/terms/Security/publishedTime",
  4250. compact="security_publishedTime",
  4251. )
  4252. # Specified the time and date when a vulnerability was withdrawn.
  4253. cls._add_property(
  4254. "security_withdrawnTime",
  4255. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  4256. iri="https://spdx.org/rdf/3.0.1/terms/Security/withdrawnTime",
  4257. compact="security_withdrawnTime",
  4258. )
  4259. # A distinct article or unit related to Software.
  4260. @register("https://spdx.org/rdf/3.0.1/terms/Software/SoftwareArtifact", compact_type="software_SoftwareArtifact", abstract=True)
  4261. class software_SoftwareArtifact(Artifact):
  4262. NODE_KIND = NodeKind.IRI
  4263. ID_ALIAS = "spdxId"
  4264. NAMED_INDIVIDUALS = {
  4265. }
  4266. @classmethod
  4267. def _register_props(cls):
  4268. super()._register_props()
  4269. # Provides additional purpose information of the software artifact.
  4270. cls._add_property(
  4271. "software_additionalPurpose",
  4272. ListProp(EnumProp([
  4273. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application", "application"),
  4274. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive", "archive"),
  4275. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom", "bom"),
  4276. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/configuration", "configuration"),
  4277. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/container", "container"),
  4278. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/data", "data"),
  4279. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/device", "device"),
  4280. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/deviceDriver", "deviceDriver"),
  4281. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/diskImage", "diskImage"),
  4282. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/documentation", "documentation"),
  4283. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/evidence", "evidence"),
  4284. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/executable", "executable"),
  4285. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/file", "file"),
  4286. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/filesystemImage", "filesystemImage"),
  4287. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/firmware", "firmware"),
  4288. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/framework", "framework"),
  4289. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/install", "install"),
  4290. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/library", "library"),
  4291. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/manifest", "manifest"),
  4292. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/model", "model"),
  4293. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/module", "module"),
  4294. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/operatingSystem", "operatingSystem"),
  4295. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/other", "other"),
  4296. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/patch", "patch"),
  4297. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/platform", "platform"),
  4298. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/requirement", "requirement"),
  4299. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source", "source"),
  4300. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification", "specification"),
  4301. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test", "test"),
  4302. ])),
  4303. iri="https://spdx.org/rdf/3.0.1/terms/Software/additionalPurpose",
  4304. compact="software_additionalPurpose",
  4305. )
  4306. # Provides a place for the SPDX data creator to record acknowledgement text for
  4307. # a software Package, File or Snippet.
  4308. cls._add_property(
  4309. "software_attributionText",
  4310. ListProp(StringProp()),
  4311. iri="https://spdx.org/rdf/3.0.1/terms/Software/attributionText",
  4312. compact="software_attributionText",
  4313. )
  4314. # A canonical, unique, immutable identifier of the artifact content, that may be
  4315. # used for verifying its identity and/or integrity.
  4316. cls._add_property(
  4317. "software_contentIdentifier",
  4318. ListProp(ObjectProp(software_ContentIdentifier, False)),
  4319. iri="https://spdx.org/rdf/3.0.1/terms/Software/contentIdentifier",
  4320. compact="software_contentIdentifier",
  4321. )
  4322. # Identifies the text of one or more copyright notices for a software Package,
  4323. # File or Snippet, if any.
  4324. cls._add_property(
  4325. "software_copyrightText",
  4326. StringProp(),
  4327. iri="https://spdx.org/rdf/3.0.1/terms/Software/copyrightText",
  4328. compact="software_copyrightText",
  4329. )
  4330. # Provides information about the primary purpose of the software artifact.
  4331. cls._add_property(
  4332. "software_primaryPurpose",
  4333. EnumProp([
  4334. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/application", "application"),
  4335. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/archive", "archive"),
  4336. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/bom", "bom"),
  4337. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/configuration", "configuration"),
  4338. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/container", "container"),
  4339. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/data", "data"),
  4340. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/device", "device"),
  4341. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/deviceDriver", "deviceDriver"),
  4342. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/diskImage", "diskImage"),
  4343. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/documentation", "documentation"),
  4344. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/evidence", "evidence"),
  4345. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/executable", "executable"),
  4346. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/file", "file"),
  4347. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/filesystemImage", "filesystemImage"),
  4348. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/firmware", "firmware"),
  4349. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/framework", "framework"),
  4350. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/install", "install"),
  4351. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/library", "library"),
  4352. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/manifest", "manifest"),
  4353. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/model", "model"),
  4354. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/module", "module"),
  4355. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/operatingSystem", "operatingSystem"),
  4356. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/other", "other"),
  4357. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/patch", "patch"),
  4358. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/platform", "platform"),
  4359. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/requirement", "requirement"),
  4360. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/source", "source"),
  4361. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/specification", "specification"),
  4362. ("https://spdx.org/rdf/3.0.1/terms/Software/SoftwarePurpose/test", "test"),
  4363. ]),
  4364. iri="https://spdx.org/rdf/3.0.1/terms/Software/primaryPurpose",
  4365. compact="software_primaryPurpose",
  4366. )
  4367. # A container for a grouping of SPDX-3.0 content characterizing details
  4368. # (provenence, composition, licensing, etc.) about a product.
  4369. @register("https://spdx.org/rdf/3.0.1/terms/Core/Bom", compact_type="Bom", abstract=False)
  4370. class Bom(Bundle):
  4371. NODE_KIND = NodeKind.IRI
  4372. ID_ALIAS = "spdxId"
  4373. NAMED_INDIVIDUALS = {
  4374. }
  4375. # A license that is not listed on the SPDX License List.
  4376. @register("https://spdx.org/rdf/3.0.1/terms/ExpandedLicensing/CustomLicense", compact_type="expandedlicensing_CustomLicense", abstract=False)
  4377. class expandedlicensing_CustomLicense(expandedlicensing_License):
  4378. NODE_KIND = NodeKind.IRI
  4379. ID_ALIAS = "spdxId"
  4380. NAMED_INDIVIDUALS = {
  4381. }
  4382. # Connects a vulnerability and an element designating the element as a product
  4383. # affected by the vulnerability.
  4384. @register("https://spdx.org/rdf/3.0.1/terms/Security/VexAffectedVulnAssessmentRelationship", compact_type="security_VexAffectedVulnAssessmentRelationship", abstract=False)
  4385. class security_VexAffectedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
  4386. NODE_KIND = NodeKind.IRI
  4387. ID_ALIAS = "spdxId"
  4388. NAMED_INDIVIDUALS = {
  4389. }
  4390. @classmethod
  4391. def _register_props(cls):
  4392. super()._register_props()
  4393. # Provides advise on how to mitigate or remediate a vulnerability when a VEX product
  4394. # is affected by it.
  4395. cls._add_property(
  4396. "security_actionStatement",
  4397. StringProp(),
  4398. iri="https://spdx.org/rdf/3.0.1/terms/Security/actionStatement",
  4399. min_count=1,
  4400. compact="security_actionStatement",
  4401. )
  4402. # Records the time when a recommended action was communicated in a VEX statement
  4403. # to mitigate a vulnerability.
  4404. cls._add_property(
  4405. "security_actionStatementTime",
  4406. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  4407. iri="https://spdx.org/rdf/3.0.1/terms/Security/actionStatementTime",
  4408. compact="security_actionStatementTime",
  4409. )
  4410. # Links a vulnerability and elements representing products (in the VEX sense) where
  4411. # a fix has been applied and are no longer affected.
  4412. @register("https://spdx.org/rdf/3.0.1/terms/Security/VexFixedVulnAssessmentRelationship", compact_type="security_VexFixedVulnAssessmentRelationship", abstract=False)
  4413. class security_VexFixedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
  4414. NODE_KIND = NodeKind.IRI
  4415. ID_ALIAS = "spdxId"
  4416. NAMED_INDIVIDUALS = {
  4417. }
  4418. # Links a vulnerability and one or more elements designating the latter as products
  4419. # not affected by the vulnerability.
  4420. @register("https://spdx.org/rdf/3.0.1/terms/Security/VexNotAffectedVulnAssessmentRelationship", compact_type="security_VexNotAffectedVulnAssessmentRelationship", abstract=False)
  4421. class security_VexNotAffectedVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
  4422. NODE_KIND = NodeKind.IRI
  4423. ID_ALIAS = "spdxId"
  4424. NAMED_INDIVIDUALS = {
  4425. }
  4426. @classmethod
  4427. def _register_props(cls):
  4428. super()._register_props()
  4429. # Explains why a VEX product is not affected by a vulnerability. It is an
  4430. # alternative in VexNotAffectedVulnAssessmentRelationship to the machine-readable
  4431. # justification label.
  4432. cls._add_property(
  4433. "security_impactStatement",
  4434. StringProp(),
  4435. iri="https://spdx.org/rdf/3.0.1/terms/Security/impactStatement",
  4436. compact="security_impactStatement",
  4437. )
  4438. # Timestamp of impact statement.
  4439. cls._add_property(
  4440. "security_impactStatementTime",
  4441. DateTimeStampProp(pattern=r"^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$",),
  4442. iri="https://spdx.org/rdf/3.0.1/terms/Security/impactStatementTime",
  4443. compact="security_impactStatementTime",
  4444. )
  4445. # Impact justification label to be used when linking a vulnerability to an element
  4446. # representing a VEX product with a VexNotAffectedVulnAssessmentRelationship
  4447. # relationship.
  4448. cls._add_property(
  4449. "security_justificationType",
  4450. EnumProp([
  4451. ("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/componentNotPresent", "componentNotPresent"),
  4452. ("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/inlineMitigationsAlreadyExist", "inlineMitigationsAlreadyExist"),
  4453. ("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeCannotBeControlledByAdversary", "vulnerableCodeCannotBeControlledByAdversary"),
  4454. ("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotInExecutePath", "vulnerableCodeNotInExecutePath"),
  4455. ("https://spdx.org/rdf/3.0.1/terms/Security/VexJustificationType/vulnerableCodeNotPresent", "vulnerableCodeNotPresent"),
  4456. ]),
  4457. iri="https://spdx.org/rdf/3.0.1/terms/Security/justificationType",
  4458. compact="security_justificationType",
  4459. )
  4460. # Designates elements as products where the impact of a vulnerability is being
  4461. # investigated.
  4462. @register("https://spdx.org/rdf/3.0.1/terms/Security/VexUnderInvestigationVulnAssessmentRelationship", compact_type="security_VexUnderInvestigationVulnAssessmentRelationship", abstract=False)
  4463. class security_VexUnderInvestigationVulnAssessmentRelationship(security_VexVulnAssessmentRelationship):
  4464. NODE_KIND = NodeKind.IRI
  4465. ID_ALIAS = "spdxId"
  4466. NAMED_INDIVIDUALS = {
  4467. }
  4468. # Refers to any object that stores content on a computer.
  4469. @register("https://spdx.org/rdf/3.0.1/terms/Software/File", compact_type="software_File", abstract=False)
  4470. class software_File(software_SoftwareArtifact):
  4471. NODE_KIND = NodeKind.IRI
  4472. ID_ALIAS = "spdxId"
  4473. NAMED_INDIVIDUALS = {
  4474. }
  4475. @classmethod
  4476. def _register_props(cls):
  4477. super()._register_props()
  4478. # Provides information about the content type of an Element or a Property.
  4479. cls._add_property(
  4480. "contentType",
  4481. StringProp(pattern=r"^[^\/]+\/[^\/]+$",),
  4482. iri="https://spdx.org/rdf/3.0.1/terms/Core/contentType",
  4483. compact="contentType",
  4484. )
  4485. # Describes if a given file is a directory or non-directory kind of file.
  4486. cls._add_property(
  4487. "software_fileKind",
  4488. EnumProp([
  4489. ("https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/directory", "directory"),
  4490. ("https://spdx.org/rdf/3.0.1/terms/Software/FileKindType/file", "file"),
  4491. ]),
  4492. iri="https://spdx.org/rdf/3.0.1/terms/Software/fileKind",
  4493. compact="software_fileKind",
  4494. )
  4495. # Refers to any unit of content that can be associated with a distribution of
  4496. # software.
  4497. @register("https://spdx.org/rdf/3.0.1/terms/Software/Package", compact_type="software_Package", abstract=False)
  4498. class software_Package(software_SoftwareArtifact):
  4499. NODE_KIND = NodeKind.IRI
  4500. ID_ALIAS = "spdxId"
  4501. NAMED_INDIVIDUALS = {
  4502. }
  4503. @classmethod
  4504. def _register_props(cls):
  4505. super()._register_props()
  4506. # Identifies the download Uniform Resource Identifier for the package at the time
  4507. # that the document was created.
  4508. cls._add_property(
  4509. "software_downloadLocation",
  4510. AnyURIProp(),
  4511. iri="https://spdx.org/rdf/3.0.1/terms/Software/downloadLocation",
  4512. compact="software_downloadLocation",
  4513. )
  4514. # A place for the SPDX document creator to record a website that serves as the
  4515. # package's home page.
  4516. cls._add_property(
  4517. "software_homePage",
  4518. AnyURIProp(),
  4519. iri="https://spdx.org/rdf/3.0.1/terms/Software/homePage",
  4520. compact="software_homePage",
  4521. )
  4522. # Provides a place for the SPDX data creator to record the package URL string
  4523. # (in accordance with the Package URL specification) for a software Package.
  4524. cls._add_property(
  4525. "software_packageUrl",
  4526. AnyURIProp(),
  4527. iri="https://spdx.org/rdf/3.0.1/terms/Software/packageUrl",
  4528. compact="software_packageUrl",
  4529. )
  4530. # Identify the version of a package.
  4531. cls._add_property(
  4532. "software_packageVersion",
  4533. StringProp(),
  4534. iri="https://spdx.org/rdf/3.0.1/terms/Software/packageVersion",
  4535. compact="software_packageVersion",
  4536. )
  4537. # Records any relevant background information or additional comments
  4538. # about the origin of the package.
  4539. cls._add_property(
  4540. "software_sourceInfo",
  4541. StringProp(),
  4542. iri="https://spdx.org/rdf/3.0.1/terms/Software/sourceInfo",
  4543. compact="software_sourceInfo",
  4544. )
  4545. # A collection of SPDX Elements describing a single package.
  4546. @register("https://spdx.org/rdf/3.0.1/terms/Software/Sbom", compact_type="software_Sbom", abstract=False)
  4547. class software_Sbom(Bom):
  4548. NODE_KIND = NodeKind.IRI
  4549. ID_ALIAS = "spdxId"
  4550. NAMED_INDIVIDUALS = {
  4551. }
  4552. @classmethod
  4553. def _register_props(cls):
  4554. super()._register_props()
  4555. # Provides information about the type of an SBOM.
  4556. cls._add_property(
  4557. "software_sbomType",
  4558. ListProp(EnumProp([
  4559. ("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/analyzed", "analyzed"),
  4560. ("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/build", "build"),
  4561. ("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/deployed", "deployed"),
  4562. ("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/design", "design"),
  4563. ("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/runtime", "runtime"),
  4564. ("https://spdx.org/rdf/3.0.1/terms/Software/SbomType/source", "source"),
  4565. ])),
  4566. iri="https://spdx.org/rdf/3.0.1/terms/Software/sbomType",
  4567. compact="software_sbomType",
  4568. )
  4569. # Describes a certain part of a file.
  4570. @register("https://spdx.org/rdf/3.0.1/terms/Software/Snippet", compact_type="software_Snippet", abstract=False)
  4571. class software_Snippet(software_SoftwareArtifact):
  4572. NODE_KIND = NodeKind.IRI
  4573. ID_ALIAS = "spdxId"
  4574. NAMED_INDIVIDUALS = {
  4575. }
  4576. @classmethod
  4577. def _register_props(cls):
  4578. super()._register_props()
  4579. # Defines the byte range in the original host file that the snippet information
  4580. # applies to.
  4581. cls._add_property(
  4582. "software_byteRange",
  4583. ObjectProp(PositiveIntegerRange, False),
  4584. iri="https://spdx.org/rdf/3.0.1/terms/Software/byteRange",
  4585. compact="software_byteRange",
  4586. )
  4587. # Defines the line range in the original host file that the snippet information
  4588. # applies to.
  4589. cls._add_property(
  4590. "software_lineRange",
  4591. ObjectProp(PositiveIntegerRange, False),
  4592. iri="https://spdx.org/rdf/3.0.1/terms/Software/lineRange",
  4593. compact="software_lineRange",
  4594. )
  4595. # Defines the original host file that the snippet information applies to.
  4596. cls._add_property(
  4597. "software_snippetFromFile",
  4598. ObjectProp(software_File, True),
  4599. iri="https://spdx.org/rdf/3.0.1/terms/Software/snippetFromFile",
  4600. min_count=1,
  4601. compact="software_snippetFromFile",
  4602. )
  4603. # Specifies an AI package and its associated information.
  4604. @register("https://spdx.org/rdf/3.0.1/terms/AI/AIPackage", compact_type="ai_AIPackage", abstract=False)
  4605. class ai_AIPackage(software_Package):
  4606. NODE_KIND = NodeKind.IRI
  4607. ID_ALIAS = "spdxId"
  4608. NAMED_INDIVIDUALS = {
  4609. }
  4610. @classmethod
  4611. def _register_props(cls):
  4612. super()._register_props()
  4613. # Indicates whether the system can perform a decision or action without human
  4614. # involvement or guidance.
  4615. cls._add_property(
  4616. "ai_autonomyType",
  4617. EnumProp([
  4618. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no", "no"),
  4619. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion", "noAssertion"),
  4620. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes", "yes"),
  4621. ]),
  4622. iri="https://spdx.org/rdf/3.0.1/terms/AI/autonomyType",
  4623. compact="ai_autonomyType",
  4624. )
  4625. # Captures the domain in which the AI package can be used.
  4626. cls._add_property(
  4627. "ai_domain",
  4628. ListProp(StringProp()),
  4629. iri="https://spdx.org/rdf/3.0.1/terms/AI/domain",
  4630. compact="ai_domain",
  4631. )
  4632. # Indicates the amount of energy consumption incurred by an AI model.
  4633. cls._add_property(
  4634. "ai_energyConsumption",
  4635. ObjectProp(ai_EnergyConsumption, False),
  4636. iri="https://spdx.org/rdf/3.0.1/terms/AI/energyConsumption",
  4637. compact="ai_energyConsumption",
  4638. )
  4639. # Records a hyperparameter used to build the AI model contained in the AI
  4640. # package.
  4641. cls._add_property(
  4642. "ai_hyperparameter",
  4643. ListProp(ObjectProp(DictionaryEntry, False)),
  4644. iri="https://spdx.org/rdf/3.0.1/terms/AI/hyperparameter",
  4645. compact="ai_hyperparameter",
  4646. )
  4647. # Provides relevant information about the AI software, not including the model
  4648. # description.
  4649. cls._add_property(
  4650. "ai_informationAboutApplication",
  4651. StringProp(),
  4652. iri="https://spdx.org/rdf/3.0.1/terms/AI/informationAboutApplication",
  4653. compact="ai_informationAboutApplication",
  4654. )
  4655. # Describes relevant information about different steps of the training process.
  4656. cls._add_property(
  4657. "ai_informationAboutTraining",
  4658. StringProp(),
  4659. iri="https://spdx.org/rdf/3.0.1/terms/AI/informationAboutTraining",
  4660. compact="ai_informationAboutTraining",
  4661. )
  4662. # Captures a limitation of the AI software.
  4663. cls._add_property(
  4664. "ai_limitation",
  4665. StringProp(),
  4666. iri="https://spdx.org/rdf/3.0.1/terms/AI/limitation",
  4667. compact="ai_limitation",
  4668. )
  4669. # Records the measurement of prediction quality of the AI model.
  4670. cls._add_property(
  4671. "ai_metric",
  4672. ListProp(ObjectProp(DictionaryEntry, False)),
  4673. iri="https://spdx.org/rdf/3.0.1/terms/AI/metric",
  4674. compact="ai_metric",
  4675. )
  4676. # Captures the threshold that was used for computation of a metric described in
  4677. # the metric field.
  4678. cls._add_property(
  4679. "ai_metricDecisionThreshold",
  4680. ListProp(ObjectProp(DictionaryEntry, False)),
  4681. iri="https://spdx.org/rdf/3.0.1/terms/AI/metricDecisionThreshold",
  4682. compact="ai_metricDecisionThreshold",
  4683. )
  4684. # Describes all the preprocessing steps applied to the training data before the
  4685. # model training.
  4686. cls._add_property(
  4687. "ai_modelDataPreprocessing",
  4688. ListProp(StringProp()),
  4689. iri="https://spdx.org/rdf/3.0.1/terms/AI/modelDataPreprocessing",
  4690. compact="ai_modelDataPreprocessing",
  4691. )
  4692. # Describes methods that can be used to explain the results from the AI model.
  4693. cls._add_property(
  4694. "ai_modelExplainability",
  4695. ListProp(StringProp()),
  4696. iri="https://spdx.org/rdf/3.0.1/terms/AI/modelExplainability",
  4697. compact="ai_modelExplainability",
  4698. )
  4699. # Records the results of general safety risk assessment of the AI system.
  4700. cls._add_property(
  4701. "ai_safetyRiskAssessment",
  4702. EnumProp([
  4703. ("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/high", "high"),
  4704. ("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/low", "low"),
  4705. ("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/medium", "medium"),
  4706. ("https://spdx.org/rdf/3.0.1/terms/AI/SafetyRiskAssessmentType/serious", "serious"),
  4707. ]),
  4708. iri="https://spdx.org/rdf/3.0.1/terms/AI/safetyRiskAssessment",
  4709. compact="ai_safetyRiskAssessment",
  4710. )
  4711. # Captures a standard that is being complied with.
  4712. cls._add_property(
  4713. "ai_standardCompliance",
  4714. ListProp(StringProp()),
  4715. iri="https://spdx.org/rdf/3.0.1/terms/AI/standardCompliance",
  4716. compact="ai_standardCompliance",
  4717. )
  4718. # Records the type of the model used in the AI software.
  4719. cls._add_property(
  4720. "ai_typeOfModel",
  4721. ListProp(StringProp()),
  4722. iri="https://spdx.org/rdf/3.0.1/terms/AI/typeOfModel",
  4723. compact="ai_typeOfModel",
  4724. )
  4725. # Records if sensitive personal information is used during model training or
  4726. # could be used during the inference.
  4727. cls._add_property(
  4728. "ai_useSensitivePersonalInformation",
  4729. EnumProp([
  4730. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no", "no"),
  4731. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion", "noAssertion"),
  4732. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes", "yes"),
  4733. ]),
  4734. iri="https://spdx.org/rdf/3.0.1/terms/AI/useSensitivePersonalInformation",
  4735. compact="ai_useSensitivePersonalInformation",
  4736. )
  4737. # Specifies a data package and its associated information.
  4738. @register("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetPackage", compact_type="dataset_DatasetPackage", abstract=False)
  4739. class dataset_DatasetPackage(software_Package):
  4740. NODE_KIND = NodeKind.IRI
  4741. ID_ALIAS = "spdxId"
  4742. NAMED_INDIVIDUALS = {
  4743. }
  4744. @classmethod
  4745. def _register_props(cls):
  4746. super()._register_props()
  4747. # Describes the anonymization methods used.
  4748. cls._add_property(
  4749. "dataset_anonymizationMethodUsed",
  4750. ListProp(StringProp()),
  4751. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/anonymizationMethodUsed",
  4752. compact="dataset_anonymizationMethodUsed",
  4753. )
  4754. # Describes the confidentiality level of the data points contained in the dataset.
  4755. cls._add_property(
  4756. "dataset_confidentialityLevel",
  4757. EnumProp([
  4758. ("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/amber", "amber"),
  4759. ("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/clear", "clear"),
  4760. ("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/green", "green"),
  4761. ("https://spdx.org/rdf/3.0.1/terms/Dataset/ConfidentialityLevelType/red", "red"),
  4762. ]),
  4763. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/confidentialityLevel",
  4764. compact="dataset_confidentialityLevel",
  4765. )
  4766. # Describes how the dataset was collected.
  4767. cls._add_property(
  4768. "dataset_dataCollectionProcess",
  4769. StringProp(),
  4770. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/dataCollectionProcess",
  4771. compact="dataset_dataCollectionProcess",
  4772. )
  4773. # Describes the preprocessing steps that were applied to the raw data to create the given dataset.
  4774. cls._add_property(
  4775. "dataset_dataPreprocessing",
  4776. ListProp(StringProp()),
  4777. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/dataPreprocessing",
  4778. compact="dataset_dataPreprocessing",
  4779. )
  4780. # The field describes the availability of a dataset.
  4781. cls._add_property(
  4782. "dataset_datasetAvailability",
  4783. EnumProp([
  4784. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/clickthrough", "clickthrough"),
  4785. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/directDownload", "directDownload"),
  4786. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/query", "query"),
  4787. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/registration", "registration"),
  4788. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetAvailabilityType/scrapingScript", "scrapingScript"),
  4789. ]),
  4790. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetAvailability",
  4791. compact="dataset_datasetAvailability",
  4792. )
  4793. # Describes potentially noisy elements of the dataset.
  4794. cls._add_property(
  4795. "dataset_datasetNoise",
  4796. StringProp(),
  4797. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetNoise",
  4798. compact="dataset_datasetNoise",
  4799. )
  4800. # Captures the size of the dataset.
  4801. cls._add_property(
  4802. "dataset_datasetSize",
  4803. NonNegativeIntegerProp(),
  4804. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetSize",
  4805. compact="dataset_datasetSize",
  4806. )
  4807. # Describes the type of the given dataset.
  4808. cls._add_property(
  4809. "dataset_datasetType",
  4810. ListProp(EnumProp([
  4811. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/audio", "audio"),
  4812. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/categorical", "categorical"),
  4813. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/graph", "graph"),
  4814. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/image", "image"),
  4815. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/noAssertion", "noAssertion"),
  4816. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/numeric", "numeric"),
  4817. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/other", "other"),
  4818. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/sensor", "sensor"),
  4819. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/structured", "structured"),
  4820. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/syntactic", "syntactic"),
  4821. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/text", "text"),
  4822. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timeseries", "timeseries"),
  4823. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/timestamp", "timestamp"),
  4824. ("https://spdx.org/rdf/3.0.1/terms/Dataset/DatasetType/video", "video"),
  4825. ])),
  4826. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetType",
  4827. min_count=1,
  4828. compact="dataset_datasetType",
  4829. )
  4830. # Describes a mechanism to update the dataset.
  4831. cls._add_property(
  4832. "dataset_datasetUpdateMechanism",
  4833. StringProp(),
  4834. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/datasetUpdateMechanism",
  4835. compact="dataset_datasetUpdateMechanism",
  4836. )
  4837. # Describes if any sensitive personal information is present in the dataset.
  4838. cls._add_property(
  4839. "dataset_hasSensitivePersonalInformation",
  4840. EnumProp([
  4841. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/no", "no"),
  4842. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/noAssertion", "noAssertion"),
  4843. ("https://spdx.org/rdf/3.0.1/terms/Core/PresenceType/yes", "yes"),
  4844. ]),
  4845. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/hasSensitivePersonalInformation",
  4846. compact="dataset_hasSensitivePersonalInformation",
  4847. )
  4848. # Describes what the given dataset should be used for.
  4849. cls._add_property(
  4850. "dataset_intendedUse",
  4851. StringProp(),
  4852. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/intendedUse",
  4853. compact="dataset_intendedUse",
  4854. )
  4855. # Records the biases that the dataset is known to encompass.
  4856. cls._add_property(
  4857. "dataset_knownBias",
  4858. ListProp(StringProp()),
  4859. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/knownBias",
  4860. compact="dataset_knownBias",
  4861. )
  4862. # Describes a sensor used for collecting the data.
  4863. cls._add_property(
  4864. "dataset_sensor",
  4865. ListProp(ObjectProp(DictionaryEntry, False)),
  4866. iri="https://spdx.org/rdf/3.0.1/terms/Dataset/sensor",
  4867. compact="dataset_sensor",
  4868. )
  4869. """Format Guard"""
  4870. # fmt: on
  4871. def main():
  4872. import argparse
  4873. from pathlib import Path
  4874. parser = argparse.ArgumentParser(description="Python SHACL model test")
  4875. parser.add_argument("infile", type=Path, help="Input file")
  4876. parser.add_argument("--print", action="store_true", help="Print object tree")
  4877. parser.add_argument("--outfile", type=Path, help="Output file")
  4878. args = parser.parse_args()
  4879. objectset = SHACLObjectSet()
  4880. with args.infile.open("r") as f:
  4881. d = JSONLDDeserializer()
  4882. d.read(f, objectset)
  4883. if args.print:
  4884. print_tree(objectset.objects)
  4885. if args.outfile:
  4886. with args.outfile.open("wb") as f:
  4887. s = JSONLDSerializer()
  4888. s.write(objectset, f)
  4889. return 0
  4890. if __name__ == "__main__":
  4891. sys.exit(main())