Skip to content

Commit

Permalink
fixes transaction error due to redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
meghfossa committed Oct 19, 2023
1 parent a11e107 commit aa263dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- golang: Updates go.mod parser to be compatible with golang v1.21. ([#1304](https://github.com/fossas/fossa-cli/pull/1304))
- `fossa list-targets`: list-target command supports `--format` option with: `ndjson`, `text`, and `legacy`. ([#1296](https://github.com/fossas/fossa-cli/pull/1296))
- container scanning: fixes transaction errors due to redirection ([]())

## v3.8.17

Expand Down
23 changes: 13 additions & 10 deletions src/Control/Carrier/ContainerRegistryApi/Authorization.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import Network.HTTP.Client (
applyBearerAuth,
parseRequest,
)
import Network.HTTP.Types (methodGet, statusCode)
import Network.HTTP.Types (methodGet, statusCode, methodHead)

Check failure on line 49 in src/Control/Carrier/ContainerRegistryApi/Authorization.hs

View workflow job for this annotation

GitHub Actions / macOS-build

The import of ‘methodGet, methodHead’

Check failure on line 49 in src/Control/Carrier/ContainerRegistryApi/Authorization.hs

View workflow job for this annotation

GitHub Actions / macOS-build

The import of ‘methodGet, methodHead’

Check failure on line 49 in src/Control/Carrier/ContainerRegistryApi/Authorization.hs

View workflow job for this annotation

GitHub Actions / Windows-build

The import of ‘methodGet, methodHead’
import Network.HTTP.Types.Header (
hAuthorization,
hWWWAuthenticate,
Expand Down Expand Up @@ -99,16 +99,19 @@ applyAuthToken (Just (BearerAuthToken token)) r =
-- If we don't strip auth headers, on redirect, depending on how
-- blobs/manifest are retrieved cloud vendor may throw 'Bad Request' error.
stripAuthHeaderOnRedirect :: Request -> Request
stripAuthHeaderOnRedirect r =
if ((isAwsECR || isAzure) && method r == methodGet)
then r{shouldStripHeaderOnRedirect = (== hAuthorization)}
else r
where
isAwsECR :: Bool
isAwsECR = "amazonaws.com" `isInfixOf` decodeUtf8 (host r)
stripAuthHeaderOnRedirect r = r{shouldStripHeaderOnRedirect = (== hAuthorization)}
-- if ((isAwsECR || isAzure || isDocker) && (method r == methodGet || method r == methodHead))
-- then r{shouldStripHeaderOnRedirect = (== hAuthorization)}
-- else r
-- where
-- isAwsECR :: Bool
-- isAwsECR = "amazonaws.com" `isInfixOf` decodeUtf8 (host r)

-- isAzure :: Bool
-- isAzure = "azurecr.io" `isInfixOf` decodeUtf8 (host r)

isAzure :: Bool
isAzure = "azurecr.io" `isInfixOf` decodeUtf8 (host r)
-- isDocker :: Bool
-- isDocker = "docker.io" `isInfixOf` decodeUtf8 (host r)

-- | Generates Auth Token For Request.
--
Expand Down

0 comments on commit aa263dc

Please sign in to comment.