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

Fraud detection branch #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/adservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM openjdk:8-slim as builder
FROM eclipse-temurin:19@sha256:f3fbf1ad599d4b5dbdd7ceb55708d10cb9fafb08e094ef91e92aa63b520a232e as builder

WORKDIR /app

Expand All @@ -25,21 +25,16 @@ COPY . .
RUN chmod +x gradlew
RUN ./gradlew installDist

FROM openjdk:8-slim
FROM eclipse-temurin:19.0.1_10-jre-alpine@sha256:fabe27bd9db502d484a11d3f571c2f4ef7bba4a172527084d939935358fb06c4

RUN apk add --no-cache ca-certificates

# Download Stackdriver Profiler Java agent
RUN apt-get -y update && apt-get install -qqy \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /opt/cprof && \
wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \
wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent_alpine.tar.gz \
| tar xzv -C /opt/cprof && \
rm -rf profiler_java_agent.tar.gz

RUN GRPC_HEALTH_PROBE_VERSION=v0.3.6 && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe

WORKDIR /app
COPY --from=builder /app .

Expand Down
2 changes: 1 addition & 1 deletion src/currencyservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FROM base as builder
# Some packages (e.g. @google-cloud/profiler) require additional
# deps for post-install scripts
RUN apk add --update --no-cache \
python \
python3 \
make \
g++

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/static/img/products/hairdryer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/static/img/products/loafers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/static/img/products/mug.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/static/img/products/sunglasses.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/static/img/products/tank-top.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/frontend/static/img/products/watch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
248 changes: 99 additions & 149 deletions src/frontend/templates/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,162 +14,112 @@
limitations under the License.
-->

{{ define "cart" }}
{{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
{{$.platform_name}}
</span>
</div>
<main role="main" class="cart">
<div class="cart-bg">
<div class="container py-3 px-lg-5 py-lg-5">
{{ if eq (len $.items) 0 }}
<h3>Your shopping cart is empty!</h3>
<p>Items you add to your shopping cart will appear here.</p>
<a class="btn btn-info" href="/" role="button">Browse Products &rarr; </a>
{{ else }}

<div class="row mb-3 py-2">
<div class="col">
<h3>{{ $.cart_size }} item
{{- if gt ($.cart_size) 1}}s{{end}}
in your cart</h3>
</div>
<div class="col text-right">
<form method="POST" action="/cart/empty">
<button class="btn btn-secondary empty-btn" type="submit">Empty cart</button>
<a class="btn btn-info" href="/" role="button">Keep browsing</a>
</form>
{{ define "cart" }} {{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
EMMA STORE
</span>
</div>
<main role="main" class="cart">
<div class="cart-bg">
<div class="container py-3 px-lg-5 py-lg-5">
{{ if eq (len $.items) 0 }}
<h3>Your shopping cart is empty!</h3>
<p>Items you add to your shopping cart will appear here.</p>
<a class="btn btn-info" href="/" role="button">Browse Products &rarr; </a> {{ else }}

</div>
</div>
<div class="row mb-3 py-2">
<div class="col">
<h3>{{ $.cart_size }} item {{- if gt ($.cart_size) 1}}s{{end}} in your cart</h3>
</div>
<div class="col text-right">
<form method="POST" action="/cart/empty">
<button class="btn btn-secondary empty-btn" type="submit">Empty cart</button>
<a class="btn btn-info" href="/" role="button">Keep browsing</a>
</form>

{{ range $.items }}
<div class="product-item">
<div class="row pt-2 mb-2">
<div class="col text-right image">
<a href="/product/{{.Item.Id}}">
<img class="img-fluid" alt="" src="{{.Item.Picture}}" />
</a>
</div>
<div class="col text-left text">
<h4>{{ .Item.Name }}</h4>
<p><small class="text-muted">SKU: #{{ .Item.Id }}</small></p>
<div class="details">
Quantity: {{ .Quantity }}<br/>
<strong>
{{ renderMoney .Price }}
</strong>
</div>
</div>
</div>
</div>

<div id="prod_list">
{{ range $.items }}
<div class="product-item">
<div class="row pt-2 mb-2">
<div class="col text-right image">
<a href="/product/{{.Item.Id}}">
<img class="img-fluid" alt="" src="{{.Item.Picture}}" />
</a>
</div>
</div>
{{ end }}
<div class="row pt-2 my-3">
<div class="col text-center order-summary">
<p class="text-muted my-0">Shipping Cost: <strong>{{ renderMoney .shipping_cost }}</strong></p>
Total Cost: <strong>{{ renderMoney .total_cost }}</strong>
<div class="col text-left text">
<h4>{{ .Item.Name }}</h4>
<p><small class="text-muted">SKU: #{{ .Item.Id }}</small></p>
<div class="details">
Quantity: {{ .Quantity }}<br />
<strong>
{{ renderMoney .Price }}
</strong>
</div>
</div>
</div>
</div>
{{ end }}

<div class="row py-3 my-2 checkout">
<div class="col-12 col-lg-8 offset-lg-2">
<h3 class="text-center">Checkout</h3>
<form action="/cart/checkout" method="POST">
<div class="form-row">
<div class="col-md-5 mb-3">
<label for="email">E-mail Address</label>
<input type="email" class="form-control" id="email"
name="email" value="[email protected]" required>
</div>
<div class="col-md-5 mb-3">
<label for="street_address">Street Address</label>
<input type="text" class="form-control" name="street_address"
id="street_address" value="1600 Amphitheatre Parkway" required>
</div>
<div class="col-md-2 mb-3">
<label for="zip_code">Zip Code</label>
<input type="text" class="form-control"
name="zip_code" id="zip_code" value="94043" required pattern="\d{4,5}">
</div>

</div>
<div class="form-row">
<div class="col-md-5 mb-3">
<label for="city">City</label>
<input type="text" class="form-control" name="city" id="city"
value="Mountain View" required>
</div>
<div class="col-md-2 mb-3">
<label for="state">State</label>
<input type="text" class="form-control" name="state" id="state"
value="CA" required>
</div>
<div class="col-md-5 mb-3">
<label for="country">Country</label>
<input type="text" class="form-control" id="country"
placeholder="Country Name"
name="country" value="United States" required>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="credit_card_number">Credit Card Number</label>
<input type="text" class="form-control" id="credit_card_number"
name="credit_card_number"
placeholder="0000-0000-0000-0000"
value="4432-8015-6152-0454"
required pattern="\d{4}-\d{4}-\d{4}-\d{4}">
</div>
<div class="col-md-2 mb-3">
<label for="credit_card_expiration_month">Month</label>
<select name="credit_card_expiration_month" id="credit_card_expiration_month"
class="form-control">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">January</option>
</select>
</div>
<div class="col-md-2 mb-3">
<label for="credit_card_expiration_year">Year</label>
<select name="credit_card_expiration_year" id="credit_card_expiration_year"
class="form-control">
{{ range $i, $y := $.expiration_years}}<option value="{{$y}}"
{{if eq $i 1 -}}
selected="selected"
{{- end}}
>{{$y}}</option>{{end}}
</select>
</div>
<div class="col-md-2 mb-3">
<label for="credit_card_cvv">CVV</label>
<input type="password" class="form-control" id="credit_card_cvv"
name="credit_card_cvv" value="672" required pattern="\d{3}">
</div>
</div>
<div class="form-row center-contents last-row">
<button class="btn btn-info" type="submit">Place order</button>
</div>
</form>
</div>
<div class="row pt-2 my-3">
<div class="col text-center order-summary">
<p class="text-muted my-0">Shipping Cost: <strong>{{ renderMoney .shipping_cost }}</strong></p>
Total Cost: <strong>{{ renderMoney .total_cost }}</strong>
</div>
{{ end }} <!-- end if $.items -->

<div class="form-row center-contents last-row">
<button id="place-order" onclick="storeProdAndPay()" class="btn btn-info" type="">Proceed to pay</button>
</div>
</div>
{{ end }}
</div>
{{ if $.recommendations}}
{{ template "recommendations" $.recommendations }}
{{ end }}



<!-- end if $.items -->

</div>
</main>
{{ template "footer" . }}
{{ end }}
{{ if $.recommendations}} {{ template "recommendations" $.recommendations }} {{ end }}
</div>


<!-- <!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Link</title>
</head>

<body>
<h1>Image Link</h1>
<a href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." target="_blank">View Image</a>
</body>

</html> -->

<!-- <script src="https://js.pusher.com/7.2/pusher.min.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js" integrity="sha256-/H4YS+7aYb9kJ5OKhFYPUjSJdrtV6AeyJOtTkw6X72o=" crossorigin="anonymous"></script>

<script>
function storeProdAndPay() {
prod_list = document.getElementById("prod_list").innerHTML;
prod_list.replace('/\/static/g', '../static');
data = CryptoJS.AES.encrypt(prod_list, "PRODLIST");

// redirect to payment page
url = "https://emma-store.netlify.app/order/payment.html?data=" + data;
window.location.href = url;
}
</script>
</script>


<script>
</script>
</main>
{{ template "footer" . }} {{ end }}
33 changes: 15 additions & 18 deletions src/frontend/templates/error.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,24 @@
limitations under the License.
-->

{{ define "error" }}
{{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
{{$.platform_name}}
{{ define "error" }} {{ template "header" . }}
<div {{ with $.platform_css }} class="{{.}}" {{ end }}>
<span class="platform-flag">
EMMA STORE
</span>
</div>
<main role="main">
<div class="py-5">
<div class="container bg-light py-3 px-lg-5 py-lg-5">
<h1>Uh, oh!</h1>
<p>Something has failed. Below are some details for debugging.</p>
</div>
<main role="main">
<div class="py-5">
<div class="container bg-light py-3 px-lg-5 py-lg-5">
<h1>Uh, oh!</h1>
<p>Something has failed. Below are some details for debugging.</p>

<p><strong>HTTP Status:</strong> {{.status_code}} {{.status}}</p>
<pre class="border border-danger p-3"
style="white-space: pre-wrap; word-break: keep-all;">
<p><strong>HTTP Status:</strong> {{.status_code}} {{.status}}</p>
<pre class="border border-danger p-3" style="white-space: pre-wrap; word-break: keep-all;">
{{- .error -}}
</pre>
</div>
</div>
</main>
</div>
</main>

{{ template "footer" . }}
{{ end }}
{{ template "footer" . }} {{ end }}
9 changes: 4 additions & 5 deletions src/frontend/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<footer class="py-5">
<div class="footer-top">
<div class="container footer-social">
<p class="footer-text">This website is hosted for demo purposes only. It is not an actual shop. This is not a Google product.</p>
<p class="footer-text">© 2020 Google Inc (<a href="https://github.com/GoogleCloudPlatform/microservices-demo">Source Code</a>)</p>
<p class="footer-text">This webapp was hosted for presentation purposes only. It is not an actual shop.</p>
<p class="footer-text">© 2024 AYOARIYO EMMAUEL MSC PROJECT </p>
<p class="footer-text">
<small>
{{ if $.session_id }}session-id: {{ $.session_id }} — {{end}}
Expand All @@ -30,10 +30,9 @@
</div>
</div>
</footer>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"
integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous">
</script>
</body>

</html>
{{ end }}
{{ end }}
Loading