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

Commit 69e512b

Browse files
authored
Merge pull request #1 from contentstack/fix/security-issues
Refactor HomeController and ProductController to add HttpGet attribut…
2 parents 3421a3a + 6ba91a1 commit 69e512b

5 files changed

Lines changed: 32 additions & 20 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
language: [ 'csharp', 'javascript' ]
31+
language: [ 'csharp' ]
3232
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
3333
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
3434

.github/workflows/sca-scan.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ jobs:
66
security-sca:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@master
9+
- name: Checkout repository
10+
uses: actions/checkout@master
11+
- name: Setup .NET Core @ Latest
12+
uses: actions/setup-dotnet@v1
13+
with:
14+
dotnet-version: "7.0.x"
15+
- name: Run Dotnet Restore
16+
run: |
17+
dotnet restore
1018
- name: Run Snyk to check for vulnerabilities
11-
uses: snyk/actions/node@master
19+
uses: snyk/actions/dotnet@master
1220
env:
1321
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
1422
with:
15-
args: --all-projects --fail-on=all
23+
args: --file=contentstack-liquid-template-example/obj/project.assets.json --fail-on=all

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2012-2022 Contentstack (http://app.contentstack.com)
3+
Copyright (c) 2012-2026 Contentstack (http://app.contentstack.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

contentstack-liquid-template-example/Controllers/HomeController.cs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,36 @@
66
using System.Threading.Tasks;
77
using Microsoft.AspNetCore.Mvc;
88
using contentstack_liquid_template_example.Models;
9-
using Contentstack.Core;
10-
using Contentstack.Core.Models;
11-
using System.IO;
12-
9+
using Contentstack.Core;
10+
using Contentstack.Core.Models;
11+
using System.IO;
12+
1313
namespace contentstack_liquid_template_example.Controllers
1414
{
1515
public class HomeController : Controller
16-
{
17-
private readonly ContentstackClient _stack;
18-
public HomeController(ContentstackClient stack) => _stack = stack;
16+
{
17+
private readonly ContentstackClient _stack;
18+
public HomeController(ContentstackClient stack) => _stack = stack;
1919

20+
[HttpGet]
2021
public async Task<IActionResult> Index()
21-
{
22-
string result = string.Empty;
23-
var query = _stack.ContentType("product").Query();
24-
ContentstackCollection<ProductModel> products = await query.Find<ProductModel>();
25-
var fileString = System.IO.File.ReadAllText(Path.GetFullPath("Views/Home/home.liquid"));
26-
var template = Template.Parse(fileString);
27-
result = template.Render(new { Products = products.Items });
28-
return View("Index", result);
22+
{
23+
string result = string.Empty;
24+
var query = _stack.ContentType("product").Query();
25+
ContentstackCollection<ProductModel> products = await query.Find<ProductModel>();
26+
var fileString = System.IO.File.ReadAllText(Path.GetFullPath("Views/Home/home.liquid"));
27+
var template = Template.Parse(fileString);
28+
result = template.Render(new { Products = products.Items });
29+
return View("Index", result);
2930
}
3031

32+
[HttpGet]
3133
public IActionResult Privacy()
3234
{
3335
return View();
3436
}
3537

38+
[HttpGet]
3639
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
3740
public IActionResult Error()
3841
{

contentstack-liquid-template-example/Controllers/ProductController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class ProductController : Controller
1919
public ProductController(ContentstackClient stack) => _stack = stack;
2020

2121
// GET: /<controller>/
22+
[HttpGet]
2223
public IActionResult Index()
2324
{
2425
return View();

0 commit comments

Comments
 (0)