Client-side navigation. For example, click Counter then Back to return here.
+
Angular CLI integration. In development mode, there's no need to run ng serve. It runs in the background automatically, so your client-side resources are dynamically built on demand and the page refreshes when you modify any file.
+
Efficient production builds. In production mode, development-time features are disabled, and your dotnet publish configuration automatically invokes ng build to produce minified, ahead-of-time compiled JavaScript files.
+
+
The ClientApp subdirectory is a standard Angular CLI application. If you open a command prompt in that directory, you can run any ng command (e.g., ng test), or use npm to install extra packages into it.
diff --git a/Server/ClientApp/src/app/home/home.component.ts b/Server/ClientApp/src/app/home/home.component.ts
new file mode 100644
index 0000000..2747b30
--- /dev/null
+++ b/Server/ClientApp/src/app/home/home.component.ts
@@ -0,0 +1,8 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'app-home',
+ templateUrl: './home.component.html',
+})
+export class HomeComponent {
+}
diff --git a/Server/ClientApp/src/app/nav-menu/nav-menu.component.css b/Server/ClientApp/src/app/nav-menu/nav-menu.component.css
new file mode 100644
index 0000000..10389ef
--- /dev/null
+++ b/Server/ClientApp/src/app/nav-menu/nav-menu.component.css
@@ -0,0 +1,18 @@
+a.navbar-brand {
+ white-space: normal;
+ text-align: center;
+ word-break: break-all;
+}
+
+html {
+ font-size: 14px;
+}
+@media (min-width: 768px) {
+ html {
+ font-size: 16px;
+ }
+}
+
+.box-shadow {
+ box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
+}
diff --git a/Server/ClientApp/src/app/nav-menu/nav-menu.component.html b/Server/ClientApp/src/app/nav-menu/nav-menu.component.html
new file mode 100644
index 0000000..dfe8c75
--- /dev/null
+++ b/Server/ClientApp/src/app/nav-menu/nav-menu.component.html
@@ -0,0 +1,44 @@
+
+
+
diff --git a/Server/ClientApp/src/app/nav-menu/nav-menu.component.ts b/Server/ClientApp/src/app/nav-menu/nav-menu.component.ts
new file mode 100644
index 0000000..327a374
--- /dev/null
+++ b/Server/ClientApp/src/app/nav-menu/nav-menu.component.ts
@@ -0,0 +1,18 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'app-nav-menu',
+ templateUrl: './nav-menu.component.html',
+ styleUrls: ['./nav-menu.component.css']
+})
+export class NavMenuComponent {
+ isExpanded = false;
+
+ collapse() {
+ this.isExpanded = false;
+ }
+
+ toggle() {
+ this.isExpanded = !this.isExpanded;
+ }
+}
diff --git a/Server/ClientApp/src/assets/.gitkeep b/Server/ClientApp/src/assets/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Server/ClientApp/src/environments/environment.prod.ts b/Server/ClientApp/src/environments/environment.prod.ts
new file mode 100644
index 0000000..3612073
--- /dev/null
+++ b/Server/ClientApp/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+ production: true
+};
diff --git a/Server/ClientApp/src/environments/environment.ts b/Server/ClientApp/src/environments/environment.ts
new file mode 100644
index 0000000..f56ff47
--- /dev/null
+++ b/Server/ClientApp/src/environments/environment.ts
@@ -0,0 +1,16 @@
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
+
+export const environment = {
+ production: false
+};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
diff --git a/Server/ClientApp/src/index.html b/Server/ClientApp/src/index.html
new file mode 100644
index 0000000..f7956f3
--- /dev/null
+++ b/Server/ClientApp/src/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+ InsecureProject
+
+
+
+
+
+
+ Loading...
+
+
diff --git a/Server/ClientApp/src/main.ts b/Server/ClientApp/src/main.ts
new file mode 100644
index 0000000..a2f708c
--- /dev/null
+++ b/Server/ClientApp/src/main.ts
@@ -0,0 +1,20 @@
+import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+
+import { AppModule } from './app/app.module';
+import { environment } from './environments/environment';
+
+export function getBaseUrl() {
+ return document.getElementsByTagName('base')[0].href;
+}
+
+const providers = [
+ { provide: 'BASE_URL', useFactory: getBaseUrl, deps: [] }
+];
+
+if (environment.production) {
+ enableProdMode();
+}
+
+platformBrowserDynamic(providers).bootstrapModule(AppModule)
+ .catch(err => console.log(err));
diff --git a/Server/ClientApp/src/polyfills.ts b/Server/ClientApp/src/polyfills.ts
new file mode 100644
index 0000000..373f538
--- /dev/null
+++ b/Server/ClientApp/src/polyfills.ts
@@ -0,0 +1,65 @@
+/**
+ * This file includes polyfills needed by Angular and is loaded before the app.
+ * You can add your own extra polyfills to this file.
+ *
+ * This file is divided into 2 sections:
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
+ * file.
+ *
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
+ *
+ * Learn more in https://angular.io/guide/browser-support
+ */
+
+/***************************************************************************************************
+ * BROWSER POLYFILLS
+ */
+
+/**
+ * IE11 requires the following for NgClass support on SVG elements
+ */
+// import 'classlist.js'; // Run `npm install --save classlist.js`.
+
+/**
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
+ */
+// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
+
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ * because those flags need to be set before `zone.js` being loaded, and webpack
+ * will put import in the top of bundle, so user need to create a separate file
+ * in this directory (for example: zone-flags.ts), and put the following flags
+ * into that file, and then add the following code before importing zone.js.
+ * import './zone-flags';
+ *
+ * The flags allowed in zone-flags.ts are listed here.
+ *
+ * The following flags will work for all browsers.
+ *
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+ *
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ *
+ * (window as any).__Zone_enable_cross_context_check = true;
+ *
+ */
+
+/***************************************************************************************************
+ * Zone JS is required by default for Angular itself.
+ */
+import 'zone.js'; // Included with Angular CLI.
+
+
+/***************************************************************************************************
+ * APPLICATION IMPORTS
+ */
diff --git a/Server/ClientApp/src/styles.css b/Server/ClientApp/src/styles.css
new file mode 100644
index 0000000..0fb2d30
--- /dev/null
+++ b/Server/ClientApp/src/styles.css
@@ -0,0 +1,20 @@
+/* You can add global styles to this file, and also import other style files */
+
+/* Provide sufficient contrast against white background */
+a {
+ color: #0366d6;
+}
+
+.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
+ box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
+}
+
+code {
+ color: #e01a76;
+}
+
+.btn-primary {
+ color: #fff;
+ background-color: #1b6ec2;
+ border-color: #1861ac;
+}
diff --git a/Server/ClientApp/src/test.ts b/Server/ClientApp/src/test.ts
new file mode 100644
index 0000000..8e1c568
--- /dev/null
+++ b/Server/ClientApp/src/test.ts
@@ -0,0 +1,13 @@
+// This file is required by karma.conf.js and loads recursively all the .spec and framework files
+
+import 'zone.js/testing';
+import { getTestBed } from '@angular/core/testing';
+import {
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting
+} from '@angular/platform-browser-dynamic/testing';
+
+getTestBed().initTestEnvironment(
+ BrowserDynamicTestingModule,
+ platformBrowserDynamicTesting()
+);
diff --git a/Server/ClientApp/tsconfig.app.json b/Server/ClientApp/tsconfig.app.json
new file mode 100644
index 0000000..82d91dc
--- /dev/null
+++ b/Server/ClientApp/tsconfig.app.json
@@ -0,0 +1,15 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./out-tsc/app",
+ "types": []
+ },
+ "files": [
+ "src/main.ts",
+ "src/polyfills.ts"
+ ],
+ "include": [
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/Server/ClientApp/tsconfig.json b/Server/ClientApp/tsconfig.json
new file mode 100644
index 0000000..51bd841
--- /dev/null
+++ b/Server/ClientApp/tsconfig.json
@@ -0,0 +1,30 @@
+{
+ "compileOnSave": false,
+ "compilerOptions": {
+ "baseUrl": "./",
+ "outDir": "./dist/out-tsc",
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ "sourceMap": true,
+ "declaration": false,
+ "downlevelIteration": true,
+ "experimentalDecorators": true,
+ "moduleResolution": "node",
+ "importHelpers": true,
+ "target": "es2022",
+ "module": "es2020",
+ "lib": [
+ "es2018",
+ "dom"
+ ],
+ "useDefineForClassFields": false
+ },
+ "angularCompilerOptions": {
+ "enableI18nLegacyMessageIdFormat": false,
+ "strictInjectionParameters": true,
+ "strictInputAccessModifiers": true,
+ "strictTemplates": true
+ }
+}
diff --git a/Server/ClientApp/tsconfig.spec.json b/Server/ClientApp/tsconfig.spec.json
new file mode 100644
index 0000000..1762d06
--- /dev/null
+++ b/Server/ClientApp/tsconfig.spec.json
@@ -0,0 +1,19 @@
+/* To learn more about this file see: https://angular.io/config/tsconfig. */
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./out-tsc/spec",
+ "types": [
+ "jasmine",
+ "node"
+ ]
+ },
+ "files": [
+ "src/test.ts",
+ "src/polyfills.ts"
+ ],
+ "include": [
+ "src/**/*.spec.ts",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/Server/Controllers/WeatherForecastController.cs b/Server/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..ed844e8
--- /dev/null
+++ b/Server/Controllers/WeatherForecastController.cs
@@ -0,0 +1,63 @@
+using Microsoft.AspNetCore.Mvc;
+using InsecureProject.Database;
+using Microsoft.EntityFrameworkCore;
+using Newtonsoft.Json;
+
+namespace InsecureProject.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class WeatherForecastController : ControllerBase
+{
+ private readonly DbModelContext _dbContext;
+ private readonly ILogger _logger;
+
+ public WeatherForecastController(DbModelContext dbContext, ILogger logger)
+ {
+ _dbContext = dbContext;
+ _logger = logger;
+ }
+
+ [HttpGet("{city}")]
+ public IEnumerable Get([FromRoute]string city)
+ {
+ _logger.LogDebug($"Get called for city {city}.");
+
+ var results = _dbContext.Forecasts.Where(f => f.City.ToLower().Equals(city.ToLower())).ToList();
+ var transformed = results
+ .Select(f => new WeatherForecast
+ {
+ Date = DateOnly.FromDateTime(DateTime.Now.AddDays(1)),
+ TemperatureC = f.Temperature,
+ Summary = f.Summary
+ });
+ var twoWeeksAgo = DateTime.Now.Subtract(TimeSpan.FromDays(14));
+ _logger.LogDebug("Two weeks ago was {twoWeeksAgo}", twoWeeksAgo);
+ var serialized = JsonConvert.SerializeObject(transformed);
+ _logger.LogDebug($"Returning { serialized } to caller.");
+
+ return transformed;
+ }
+
+ [HttpGet("insecure/{city}")]
+ public IEnumerable GetInsecure([FromRoute]string city)
+ {
+ _logger.LogDebug($"Get insecure called for city {city.Replace("\n", string.Empty).Replace("\r", string.Empty)}.");
+
+ var results = _dbContext.Forecasts.FromSqlInterpolated(
+ $"select * from Forecasts where lower(City) = lower('{city}');")
+ .ToList();
+
+ var transformed = results.Select(f => new WeatherForecast
+ {
+ Date = DateOnly.FromDateTime(DateTime.Now.AddDays(1)),
+ TemperatureC = f.Temperature,
+ Summary = f.Summary
+ }).ToList();
+
+ var serialized = JsonConvert.SerializeObject(transformed);
+ _logger.LogDebug($"Returning { serialized } to caller.");
+
+ return transformed;
+ }
+}
diff --git a/Server/Database/DbModelContext.cs b/Server/Database/DbModelContext.cs
new file mode 100644
index 0000000..ab46297
--- /dev/null
+++ b/Server/Database/DbModelContext.cs
@@ -0,0 +1,30 @@
+using Microsoft.EntityFrameworkCore;
+
+namespace InsecureProject.Database;
+
+public class DbModelContext : DbContext
+{
+ public virtual DbSet Forecasts { get; set; }
+
+ public string DbPath { get; }
+
+ public DbModelContext()
+ {
+ var folder = Environment.SpecialFolder.LocalApplicationData;
+ var path = Environment.GetFolderPath(folder);
+ DbPath = Path.Join(path, "forecast.db");
+ }
+
+ // The following configures EF to create a Sqlite database file in the
+ // special "local" folder for your platform.
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ => optionsBuilder.UseSqlite($"Data Source={DbPath}");
+}
+
+public class Forecast
+{
+ public int ForecastId { get; set; }
+ public string City { get; set; }
+ public string Summary { get; set; }
+ public int Temperature { get; set; }
+}
diff --git a/Server/InsecureProject.csproj b/Server/InsecureProject.csproj
new file mode 100644
index 0000000..e948f5f
--- /dev/null
+++ b/Server/InsecureProject.csproj
@@ -0,0 +1,62 @@
+
+
+
+ enable
+ false
+ ClientApp\
+ https://localhost:44459
+ npm start
+ enable
+ net8.0
+ true
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ wwwroot\%(RecursiveDir)%(FileName)%(Extension)
+ PreserveNewest
+ true
+
+
+
+
diff --git a/Server/Migrations/20231213201231_InitialCreate.Designer.cs b/Server/Migrations/20231213201231_InitialCreate.Designer.cs
new file mode 100644
index 0000000..bee083b
--- /dev/null
+++ b/Server/Migrations/20231213201231_InitialCreate.Designer.cs
@@ -0,0 +1,46 @@
+//
+using InsecureProject.Database;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace InsecureProject.Migrations
+{
+ [DbContext(typeof(DbModelContext))]
+ [Migration("20231213201231_InitialCreate")]
+ partial class InitialCreate
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.0");
+
+ modelBuilder.Entity("InsecureProject.Database.Forecast", b =>
+ {
+ b.Property("ForecastId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("City")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Summary")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Temperature")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ForecastId");
+
+ b.ToTable("Forecasts");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Server/Migrations/20231213201231_InitialCreate.cs b/Server/Migrations/20231213201231_InitialCreate.cs
new file mode 100644
index 0000000..037b3d7
--- /dev/null
+++ b/Server/Migrations/20231213201231_InitialCreate.cs
@@ -0,0 +1,36 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace InsecureProject.Migrations
+{
+ ///
+ public partial class InitialCreate : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Forecasts",
+ columns: table => new
+ {
+ ForecastId = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ City = table.Column(type: "TEXT", nullable: false),
+ Summary = table.Column(type: "TEXT", nullable: false),
+ Temperature = table.Column(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Forecasts", x => x.ForecastId);
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Forecasts");
+ }
+ }
+}
diff --git a/Server/Migrations/DbModelContextModelSnapshot.cs b/Server/Migrations/DbModelContextModelSnapshot.cs
new file mode 100644
index 0000000..a3a1e32
--- /dev/null
+++ b/Server/Migrations/DbModelContextModelSnapshot.cs
@@ -0,0 +1,43 @@
+//
+using InsecureProject.Database;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace InsecureProject.Migrations
+{
+ [DbContext(typeof(DbModelContext))]
+ partial class DbModelContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.0");
+
+ modelBuilder.Entity("InsecureProject.Database.Forecast", b =>
+ {
+ b.Property("ForecastId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("City")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Summary")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Temperature")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ForecastId");
+
+ b.ToTable("Forecasts");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Server/Pages/Error.cshtml b/Server/Pages/Error.cshtml
new file mode 100644
index 0000000..6f92b95
--- /dev/null
+++ b/Server/Pages/Error.cshtml
@@ -0,0 +1,26 @@
+@page
+@model ErrorModel
+@{
+ ViewData["Title"] = "Error";
+}
+
+
Error.
+
An error occurred while processing your request.
+
+@if (Model.ShowRequestId)
+{
+
+ Request ID:@Model.RequestId
+
+}
+
+
Development Mode
+
+ Swapping to the Development environment displays detailed information about the error that occurred.
+
+
+ The Development environment shouldn't be enabled for deployed applications.
+ It can result in displaying sensitive information from exceptions to end users.
+ For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
+ and restarting the app.
+