Skip to content

Commit 47bda76

Browse files
Merge branch 'main' into 3-windows-install
2 parents 48690ce + d351c02 commit 47bda76

File tree

104 files changed

+6590
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+6590
-1
lines changed

.github/workflows/codeql.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "*" ]
17+
pull_request:
18+
branches: [ "main" ]
19+
schedule:
20+
- cron: '30 12 * * 0'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
language: [ 'c-cpp' ]
46+
build-mode: [ 'automatic' ]
47+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
48+
# Use `c-cpp` to analyze code written in C, C++ or both
49+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
50+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
51+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
52+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
53+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
54+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Install libpqxx and dependencies
60+
run: |
61+
sudo apt-get update
62+
sudo apt-get install -y libpqxx-dev libpq-dev cmake g++
63+
64+
# Initializes the CodeQL tools for scanning.
65+
- name: Initialize CodeQL
66+
uses: github/codeql-action/init@v3
67+
with:
68+
languages: ${{ matrix.language }}
69+
build-mode: ${{ matrix.build-mode }}
70+
queries: security-extended,security-and-quality
71+
# If you wish to specify custom queries, you can do so here or in a config file.
72+
# By default, queries listed here will override any specified in a config file.
73+
# Prefix the list here with "+" to use these queries and those in the config file.
74+
75+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
76+
# queries: security-extended,security-and-quality
77+
78+
# If the analyze step fails for one of the languages you are analyzing with
79+
# "We were unable to automatically build your code", modify the matrix above
80+
# to set the build mode to "manual" for that language. Then modify this step
81+
# to build your code.
82+
# ℹ️ Command-line programs to run using the OS shell.
83+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
84+
85+
- name: Perform CodeQL Analysis
86+
uses: github/codeql-action/analyze@v3
87+
with:
88+
category: "/language:${{matrix.language}}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.11.35327.3
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PA 8", "PA 8\PA 8.vcxproj", "{D8F947FC-58E4-452F-BEC2-C0B905D238B6}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Debug|x64.ActiveCfg = Debug|x64
17+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Debug|x64.Build.0 = Debug|x64
18+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Debug|x86.ActiveCfg = Debug|Win32
19+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Debug|x86.Build.0 = Debug|Win32
20+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Release|x64.ActiveCfg = Release|x64
21+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Release|x64.Build.0 = Release|x64
22+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Release|x86.ActiveCfg = Release|Win32
23+
{D8F947FC-58E4-452F-BEC2-C0B905D238B6}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {FF09BBAC-5D60-476F-B3BE-58FC631E615C}
30+
EndGlobalSection
31+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// BusinessReviewAnalyzer.cpp
3+
// PostgreSQL
4+
//
5+
// Created by Kyle Parker on 10/18/24.
6+
//
7+
8+
/// TODO: Implement BusinessReviewAnalyzer!
9+
10+
#include "BusinessReviewAnalyzer.hpp"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// BusinessReviewAnalyzer.hpp
3+
// PostgreSQL
4+
//
5+
// Created by Kyle Parker on 10/18/24.
6+
//
7+
8+
/// TODO: Design BusinessReviewAnalyzer!
9+
10+
#ifndef BusinessReviewAnalyzer_hpp
11+
#define BusinessReviewAnalyzer_hpp
12+
13+
#include "../Entities/GoogleReviewEntity.hpp"
14+
15+
using std::vector;
16+
17+
class BusinessReviewAnalyzer final {
18+
vector<GoogleReviewEntity> _entites;
19+
20+
public:
21+
BusinessReviewAnalyzer(const vector<GoogleReviewEntity>);
22+
23+
/// TODO: Add your functions for analysis here!
24+
};
25+
26+
#endif /* BusinessReviewAnalyzer_hpp */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// Reviewer.hpp
3+
// PostgreSQL
4+
//
5+
// Created by Kyle Parker on 10/29/24.
6+
//
7+
8+
#ifndef Reviewer_hpp
9+
#define Reviewer_hpp
10+
11+
#include <vector>
12+
13+
using std::vector;
14+
15+
template <class T>
16+
class Reviewer {
17+
vector<T> _entities;
18+
19+
public:
20+
Reviewer();
21+
Reviewer(const vector<T>& entities);
22+
23+
Reviewer(const Reviewer& copy);
24+
Reviewer operator=(const Reviewer& rhs);
25+
26+
virtual ~Reviewer();
27+
28+
virtual vector<T> entities();
29+
30+
virtual T getMax() = 0;
31+
virtual T getMin() = 0;
32+
};
33+
34+
#endif /* Reviewer_hpp */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Files to Modify
2+
TLDR: Look for TODOs throughout the program
3+
1. Analysis/
4+
1.1 Please inherit from Reviewer and be sure to specialize the inheritee
5+
2. Tree/Tree.hpp
6+
3. Tree/Tree.cpp
7+
4. Tree/TreeNode.cpp
8+
5. Tree/TreeNode.cpp
9+
6. ReviewApp.hpp
10+
7. ReviewApp.cpp
11+
8. Files you create?
12+
13+
# Files to Look at, but Don't Modify
14+
Be sure to look at the files below:
15+
1. Anything under Entites, Database, or Types
16+
2. LoginController.hpp
17+
3. All other functions in LoginController.cpp
18+
4. NodeData.hpp
19+
5. NodeData.cpp
20+
6. TreeBase.hpp
21+
7. main.cpp
22+
23+
# Instructions
24+
See Canvas for PA instructions, requirements, and grading rubric.
25+
26+
# Users
27+
## Single Country (Country code is the login)
28+
1. username = US, password = US
29+
2. username = GB, password = GB
30+
3. username = DE, password = DE
31+
4. username = CA, password = CA
32+
5. username = BR, password = BR
33+
6. username = FR, password = FR
34+
7. username = AU, password = AU
35+
36+
## Multi Country
37+
1. username = user, password = password
38+
39+
# Install
40+
See README.md.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//
2+
// DbRepository.cpp
3+
// PostgreSQL
4+
//
5+
// Created by Kyle Parker on 10/3/24.
6+
//
7+
8+
/// Attention students: Nothing to do here!
9+
10+
#include <iostream>
11+
12+
#include "DbRepository.hpp"
13+
14+
/// Construct a controller with a given filled out URL
15+
/// @Param fullURL The complete server URL for connecting to
16+
DbRepository::DbRepository(const string& fullURL) {
17+
this->url = fullURL;
18+
}
19+
20+
/// Cleanup before destroying obejct
21+
DbRepository::~DbRepository() {
22+
23+
}
24+
25+
/// Select all rows from a given table
26+
/// @Param table The table to read everything from
27+
pqxx::result DbRepository::selectAllFrom(const string& table) const {
28+
pqxx::result results = pqxx::result();
29+
30+
try {
31+
// Connect to the database
32+
pqxx::connection conn(url);
33+
34+
// Check if the connection is open
35+
#ifdef DEBUG
36+
if (conn.is_open()) {
37+
std::cout << "Opened database successfully: " << conn.dbname() << std::endl;
38+
} else {
39+
std::cout << "Can't open database" << std::endl;
40+
return results;
41+
}
42+
#else
43+
if (!conn.is_open()) {
44+
return results;
45+
}
46+
#endif
47+
48+
// Create a non-transactional object
49+
pqxx::work trans(conn);
50+
51+
// Execute a SQL query
52+
results = trans.exec("SELECT * FROM " + table + ";");
53+
54+
// Print the result
55+
return results;
56+
57+
} catch (const pqxx::sql_error &e) {
58+
std::cerr << "SQL error: " << e.what() << std::endl;
59+
std::cerr << "Query: " << e.query() << std::endl;
60+
} catch (const std::exception &e) {
61+
std::cerr << e.what() << std::endl;
62+
}
63+
return results;
64+
}
65+
66+
/// Select all fields from a given table
67+
/// @Param fields The fields to select in
68+
/// @Param table The table to read from
69+
/// @Param where Conditionals
70+
pqxx::result DbRepository::selectWhere(const string& fields, const string& table, const string& where) const {
71+
pqxx::result results;
72+
73+
try {
74+
75+
// Connect to the database
76+
pqxx::connection conn(url);
77+
78+
// Check if the connection is open
79+
#ifdef DEBUG
80+
if (conn.is_open()) {
81+
std::cout << "Opened database successfully: " << conn.dbname() << std::endl;
82+
} else {
83+
std::cout << "Can't open database" << std::endl;
84+
return results;
85+
}
86+
#else
87+
if (!conn.is_open()) {
88+
return results;
89+
}
90+
#endif
91+
92+
// Create a transactional object
93+
pqxx::work trans(conn);
94+
95+
// Execute a SQL query
96+
results = trans.exec("SELECT " + fields + " FROM " + table + " WHERE " + where + ";");
97+
98+
} catch (const pqxx::sql_error &e) {
99+
std::cerr << "SQL error: " << e.what() << std::endl;
100+
std::cerr << "Query: " << e.query() << std::endl;
101+
} catch (const std::exception &e) {
102+
std::cerr << "Exception: " << e.what() << std::endl;
103+
}
104+
return results;
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// DbRepository.hpp
3+
// PostgreSQL
4+
//
5+
// Created by Kyle Parker on 10/3/24.
6+
//
7+
8+
/// Attention students: Nothing to do here!
9+
10+
#ifndef DbRepository_hpp
11+
#define DbRepository_hpp
12+
13+
#include <string>
14+
#include <pqxx/pqxx>
15+
16+
using std::string;
17+
18+
class DbRepository {
19+
/// Disable copy constructor
20+
DbRepository(DbRepository& copy) = delete;
21+
/// Disable = operator
22+
DbRepository operator=(const DbRepository&rhs) = delete;
23+
24+
string url;
25+
26+
public:
27+
/// Construct a controller with a given filled out URL
28+
/// @Param fullURL The complete server URL for connecting to
29+
DbRepository(const string& fullURL);
30+
31+
/// Cleanup before destroying obejct
32+
~DbRepository();
33+
34+
/// Select all rows from a given table
35+
pqxx::result selectAllFrom(const string& table) const;
36+
37+
/// Select a fields form a row where the conditions are met from the given table
38+
pqxx::result selectWhere(const string& fields, const string& table, const string& where) const;
39+
};
40+
41+
#endif /* DbRepository_hpp */

0 commit comments

Comments
 (0)