Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fetcher/redhat): fetch through proxy #410

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Conversation

MaineK00n
Copy link
Collaborator

@MaineK00n MaineK00n commented Jul 11, 2024

If this Pull Request is work in progress, Add a prefix of “[WIP]” in the title.

What did you implement:

Fixes #409

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

$ pwd
/home/user/goval-dictionary

$ cat Dockerfile
FROM golang:alpine as builder

RUN apk add --no-cache \
        git \
        make

RUN git clone -b MaineK00n/poxy https://github.com/vulsio/goval-dictionary.git
RUN cd goval-dictionary && make install

FROM alpine:3.16

LABEL maintainer sadayuki-matsuno

ENV LOGDIR /var/log/goval-dictionary
ENV WORKDIR /goval-dictionary

RUN apk add --no-cache ca-certificates \
    && mkdir -p $WORKDIR $LOGDIR

COPY --from=builder /go/bin/goval-dictionary /usr/local/bin/

VOLUME ["$WORKDIR", "$LOGDIR"]
WORKDIR $WORKDIR
ENV PWD $WORKDIR

ENTRYPOINT ["goval-dictionary"]
CMD ["--help"]

$ cat docker-compose.yaml 
services:
  app:
    build: .
    networks:       
      - app_internal
  proxy:
    image: sameersbn/squid:3.5.27-2    
    restart: always
    hostname: squid
    ports:
      - "127.0.0.1:3128:3128"
    networks:
      - app_internal
      - proxy_network
    entrypoint: >
      sh -c '
        sed -i -E "s/#\s*(acl localnet src)/acl localnet src/g" /etc/squid/squid.conf
        sed -i -E "s/#\s*(http_access allow localnet)/http_access allow localnet/g" /etc/squid/squid.conf
        /usr/sbin/squid -N
      '
      
networks:
  app_internal:
    internal: true
  proxy_network:

$ docker compose up -d

$ docker compose run --rm app fetch redhat 5
INFO[07-11|11:08:42] Fetching...                              URL=https://access.redhat.com/security/data/archive/oval_v1_20230706.tar.gz
Failed to fetch files. err: Failed to fetch OVALv1. err: Failed to fetch. err: [Failed to download. err: Get "https://access.redhat.com/security/data/archive/oval_v1_20230706.tar.gz": dial tcp: lookup access.redhat.com on 127.0.0.11:53: server misbehaving]

$ docker compose run --rm app fetch redhat 5 --http-proxy http://squid:3128
INFO[07-11|11:09:04] Fetching...                              URL=https://access.redhat.com/security/data/archive/oval_v1_20230706.tar.gz
INFO[07-11|11:09:05] Fetched                                  File=com.redhat.rhsa-RHEL5-ELS.xml Count=1172 Timestamp=2021-07-20T20:31:14
WARN[07-11|11:09:05] The fetched OVAL has not been updated for 3 days, the OVAL URL may have changed, please register a GitHub issue. GitHub=https://github.com/vulsio/goval-dictionary/issues OVAL=https://access.redhat.com/security/data/archive/oval_v1_20230706.tar.gz/com.redhat.rhsa-RHEL5-ELS.xml Timestamp=2021-07-20T20:31:14
INFO[07-11|11:09:06] Fetched                                  File=com.redhat.rhsa-RHEL5.xml Count=1172 Timestamp=2023-04-05T15:46:45
WARN[07-11|11:09:06] The fetched OVAL has not been updated for 3 days, the OVAL URL may have changed, please register a GitHub issue. GitHub=https://github.com/vulsio/goval-dictionary/issues OVAL=https://access.redhat.com/security/data/archive/oval_v1_20230706.tar.gz/com.redhat.rhsa-RHEL5.xml Timestamp=2023-04-05T15:46:45
INFO[07-11|11:09:06] Refreshing...                            Family=redhat Version=5
INFO[07-11|11:09:06] Inserting new Definitions... 
1172 / 1172 [-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 100.00% 36492 p/s
INFO[07-11|11:09:06] Finish                                   Updated=1172

Checklist:

You don't have to satisfy all of the following.

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

Reference

@MaineK00n MaineK00n self-assigned this Jul 11, 2024
@MaineK00n MaineK00n changed the title fix(fetcher/redhat): fetch through Proxy fix(fetcher/redhat): fetch through proxy Jul 11, 2024
@MaineK00n MaineK00n requested a review from shino July 11, 2024 11:24
Copy link
Contributor

@shino shino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@MaineK00n MaineK00n merged commit adcb4dc into master Jul 12, 2024
13 checks passed
@MaineK00n MaineK00n deleted the MaineK00n/poxy branch July 12, 2024 02:23
@MaineK00n MaineK00n linked an issue Jul 12, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure to fetch redhat OVALv1 under proxy environment
2 participants