| Conditions | 2 |
| Total Lines | 17 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import re |
||
| 24 | def is_content_href_remote(check_content_ref): |
||
| 25 | """ |
||
| 26 | Given an OVAL check-content-ref element, examine the 'href' attribute. |
||
| 27 | |||
| 28 | If it starts with 'http://' or 'https://', return True, otherwise |
||
| 29 | return False. |
||
| 30 | |||
| 31 | Raises RuntimeError if the ``href`` element doesn't exist. |
||
| 32 | """ |
||
| 33 | hrefattr = check_content_ref.get("href") |
||
| 34 | if hrefattr is None: |
||
| 35 | # @href attribute of <check-content-ref> is required by XCCDF standard |
||
| 36 | msg = "Invalid OVAL <check-content-ref> detected - missing the " \ |
||
| 37 | "'href' attribute!" |
||
| 38 | raise RuntimeError(msg) |
||
| 39 | |||
| 40 | return hrefattr.startswith("http://") or hrefattr.startswith("https://") |
||
| 41 | |||
| 53 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.