Skip to content
This repository was archived by the owner on Jan 27, 2022. It is now read-only.

Commit 38c7c09

Browse files
author
Ramakrishna Srinivasamurthy
committed
Create Avalon attestation verification service
1. Attestation verification service to do verify IAS AVR, DCAP quote 2. Service listens on HTTP based jrpc listener and uses format json-rpc 3. Python API makes to call to attestation service 4. Shell container having pure python packages and become light-weight. Signed-off-by: Ramakrishna Srinivasamurthy <[email protected]>
1 parent 235402f commit 38c7c09

File tree

30 files changed

+664
-144
lines changed

30 files changed

+664
-144
lines changed

BUILD.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ These docker compose files can be further customized to run multiple worker pool
117117
3. When submitting work orders using any of the sample client applications, `--worker_id` argument needs to be mentioned explicitly to choose one of the workers in the system (Note : Each pool represents a single worker). For example:
118118
```bash
119119
./generic_client.py -o --uri "http://avalon-listener:1947" \
120-
--workload_id "echo-result" --in_data "Hello" --worker_id worker-pool-2
120+
--workload_id "echo-result" --in_data "Hello" --worker_id worker-pool-2 \
121+
-as "http://avalon-avs:6090"
121122
```
122123

123124
# <a name="standalonebuild"></a>Standalone Build

avs/Dockerfile

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# Copyright 2020 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ------------------------------------------------------------------------------
15+
16+
# Description:
17+
# Builds the environment needed to build Avalon attestation
18+
# verification service
19+
#
20+
# Configuration (build) parameters
21+
# - proxy configuration: https_proxy http_proxy ftp_proxy
22+
#
23+
# Build:
24+
# $ docker build docker -f avs/Dockerfile -t avalon-avs-dev
25+
# if behind a proxy, you might want to add also below options
26+
# --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy --build-arg ftp_proxy=$ftp_proxy
27+
28+
# -------------=== build avalon attestation verification service image ===-------------
29+
FROM ubuntu:bionic as base_image
30+
31+
# Ignore timezone prompt in apt
32+
ENV DEBIAN_FRONTEND=noninteractive
33+
34+
# Add necessary packages
35+
RUN apt-get update \
36+
&& apt-get install -y -q \
37+
software-properties-common \
38+
python3-requests \
39+
python3-colorlog \
40+
python3-twisted \
41+
&& apt-get clean
42+
43+
# Make Python3 default
44+
RUN ln -sf /usr/bin/python3 /usr/bin/python
45+
46+
47+
# -------------=== python build ===-------------
48+
49+
#Build python intermediate docker image
50+
FROM ubuntu:bionic as python_image
51+
52+
53+
# Add necessary packages
54+
RUN apt-get update \
55+
&& apt-get install -y -q \
56+
ca-certificates \
57+
pkg-config \
58+
python3-pip \
59+
python3-dev \
60+
make \
61+
&& apt-get clean
62+
63+
# Install setuptools packages using pip because
64+
# these are not available in apt repository.
65+
RUN pip3 install setuptools
66+
67+
# Make Python3 default
68+
RUN ln -sf /usr/bin/python3 /usr/bin/python
69+
70+
# -------------=== Build openssl_image ===-------------
71+
72+
#Build openssl intermediate docker image
73+
FROM ubuntu:bionic as openssl_image
74+
75+
RUN apt-get update \
76+
&& apt-get install -y -q \
77+
ca-certificates \
78+
pkg-config \
79+
make \
80+
wget \
81+
tar \
82+
&& apt-get clean \
83+
&& rm -rf /var/lib/apt/lists/*
84+
85+
WORKDIR /tmp
86+
87+
# Build ("Untrusted") OpenSSL
88+
RUN OPENSSL_VER=1.1.1g \
89+
&& wget https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz \
90+
&& tar -zxf openssl-$OPENSSL_VER.tar.gz \
91+
&& cd openssl-$OPENSSL_VER/ \
92+
&& ./config \
93+
&& THREADS=8 \
94+
&& make -j$THREADS \
95+
&& make test \
96+
&& make install -j$THREADS
97+
98+
99+
# -------------=== common/cpp build ===-------------
100+
101+
#Build common/cpp intermediate docker image
102+
FROM ubuntu:bionic as common_cpp_image
103+
104+
RUN apt-get update \
105+
&& apt-get install -y -q \
106+
pkg-config \
107+
cmake \
108+
make
109+
110+
111+
# Copy openssl build artifacts from openssl_image
112+
COPY --from=openssl_image /usr/local/ssl /usr/local/ssl
113+
COPY --from=openssl_image /usr/local/bin /usr/local/bin
114+
COPY --from=openssl_image /usr/local/include /usr/local/include
115+
COPY --from=openssl_image /usr/local/lib /usr/local/lib
116+
117+
RUN ldconfig \
118+
&& ln -s /etc/ssl/certs/* /usr/local/ssl/certs/
119+
120+
ENV TCF_HOME=/project/avalon
121+
122+
COPY ./common/cpp /project/avalon/common/cpp
123+
124+
WORKDIR /project/avalon/common/cpp
125+
126+
RUN mkdir -p build \
127+
&& cd build \
128+
&& cmake .. -DUNTRUSTED_ONLY=1 \
129+
&& make
130+
131+
132+
# -------------=== common/python build ===-------------
133+
134+
#Build common/python intermediate docker image
135+
FROM python_image as common_python_image
136+
137+
COPY VERSION /project/avalon/
138+
COPY ./bin /project/avalon/bin
139+
140+
ENV TCF_HOME=/project/avalon
141+
142+
COPY ./common/python /project/avalon/common/python
143+
144+
WORKDIR /project/avalon/common/python
145+
146+
RUN echo "Building Avalon Common Python\n" \
147+
&& make
148+
149+
150+
# -------------=== common/verify_report_utils build ===-------------
151+
152+
#Build common/verify_report_utils intermediate docker image
153+
FROM python_image as verify_report_utils
154+
155+
RUN apt-get update \
156+
&& apt-get install -y -q \
157+
swig
158+
159+
# Copy openssl build artifacts from openssl_image
160+
COPY --from=openssl_image /usr/local/ssl /usr/local/ssl
161+
COPY --from=openssl_image /usr/local/bin /usr/local/bin
162+
COPY --from=openssl_image /usr/local/include /usr/local/include
163+
COPY --from=openssl_image /usr/local/lib /usr/local/lib
164+
165+
RUN ldconfig \
166+
&& ln -s /etc/ssl/certs/* /usr/local/ssl/certs/
167+
168+
COPY --from=common_cpp_image /project/avalon/common/cpp/build /project/avalon/common/cpp/build
169+
COPY VERSION /project/avalon/
170+
COPY ./bin /project/avalon/bin
171+
COPY ./common/cpp /project/avalon/common/cpp
172+
173+
ENV TCF_HOME=/project/avalon
174+
175+
COPY ./common/verify_report_utils/ias /project/avalon/common/verify_report_utils/ias
176+
177+
WORKDIR /project/avalon/common/verify_report_utils/ias
178+
179+
RUN echo "Building Avalon Verify Report Utils\n" \
180+
&& make
181+
182+
183+
# Build image for attestation version service
184+
FROM python_image as build_avs
185+
186+
#Environment setup
187+
ENV TCF_HOME=/project/avalon
188+
189+
WORKDIR /project/avalon/
190+
191+
COPY ./avs /project/avalon/avs
192+
COPY VERSION /project/avalon/
193+
COPY ./bin /project/avalon/bin
194+
195+
WORKDIR /project/avalon/avs
196+
197+
RUN echo "Building Avalon Attestation Verification service\n" \
198+
&& make
199+
200+
201+
# Build Final image and install dependent modules
202+
FROM base_image as final_image
203+
204+
COPY --from=common_python_image /project/avalon/common/python/dist/*.whl dist/
205+
COPY --from=verify_report_utils /project/avalon/common/verify_report_utils/ias/dist/*.whl dist/
206+
COPY --from=build_avs /project/avalon/avs/dist/*.whl dist/
207+
208+
# Installing wheel file requires python3-pip package.
209+
# But python3-pip package will increase size of final docker image.
210+
# So remove python3-pip package and dependencies after installing wheel file.
211+
RUN apt-get update \
212+
&& apt-get install -y -q python3-pip \
213+
&& echo "Install Attestation verification service \n" \
214+
&& pip3 install dist/*.whl \
215+
&& pip3 install json-rpc \
216+
&& echo "Remove unused packages from image\n" \
217+
&& apt-get autoremove --purge -y -q python3-pip \
218+
&& apt-get clean \
219+
&& rm -rf /var/lib/apt/lists/*
220+

avs/Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2020 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
PY_VERSION=${shell python3 --version | sed 's/Python \(3\.[0-9]\).*/\1/' | cut -b 1}
16+
MOD_VERSION=${shell ../bin/get_version}
17+
18+
WHEEL_FILE=dist/attestation_verification_service-${MOD_VERSION}-py${PY_VERSION}-none-any.whl
19+
20+
all : $(WHEEL_FILE)
21+
22+
$(WHEEL_FILE): build_ext
23+
@echo Build Distribution
24+
python3 setup.py bdist_wheel
25+
26+
build_ext:
27+
@echo Build build_ext
28+
python3 setup.py build_ext
29+
30+
build :
31+
mkdir $@
32+
33+
install:
34+
@echo INSTALLING WHEEL FILE =================
35+
pip3 install $(WHEEL_FILE)
36+
37+
clean:
38+
if pip3 uninstall --yes $(WHEEL_FILE); then \
39+
echo UNINSTALLED $(WHEEL_FILE); fi
40+
rm -rf build deps dist *.egg-info
41+
find . -iname '*.pyc' -delete
42+
find . -iname '__pycache__' -delete
43+
44+
45+
.PHONY : all
46+
.PHONY : clean
47+
.PHONY : install
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2020 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
all = []

0 commit comments

Comments
 (0)