createValidationResultFromError creates a ValidationResult from an error This ensures proper display of VSA status even when validation fails
(err error)
| 1858 | // createValidationResultFromError creates a ValidationResult from an error |
| 1859 | // This ensures proper display of VSA status even when validation fails |
| 1860 | func createValidationResultFromError(err error) *vsa.ValidationResult { |
| 1861 | if err == nil { |
| 1862 | return nil |
| 1863 | } |
| 1864 | |
| 1865 | // Determine reason code from error message |
| 1866 | reasonCode := retrievalFailedRC |
| 1867 | errMsg := err.Error() |
| 1868 | |
| 1869 | // Check for specific error types |
| 1870 | if strings.Contains(errMsg, "timeout") || strings.Contains(errMsg, "exceeded allowed execution time") { |
| 1871 | reasonCode = retrievalFailedRC |
| 1872 | } else if strings.Contains(errMsg, "no entries found") || strings.Contains(errMsg, "not found") { |
| 1873 | reasonCode = "no_vsa" |
| 1874 | } else if strings.Contains(errMsg, "signature") { |
| 1875 | reasonCode = retrievalFailedRC |
| 1876 | } |
| 1877 | |
| 1878 | return &vsa.ValidationResult{ |
| 1879 | Passed: false, |
| 1880 | Message: errMsg, |
| 1881 | SignatureVerified: false, // When retrieval fails, signature cannot be verified |
| 1882 | PredicateOutcome: "", |
| 1883 | ReasonCode: reasonCode, |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | // ResultType represents the classification of a component validation result |
| 1888 | type ResultType int |
no test coverage detected