Skip to content

Commit f424608

Browse files
authored
Development (#23)
* chore: Update GitHub Actions workflow for test and coverage * chore: Update GitHub Actions workflow for test and coverage * Update bundle nameand add component management * Update codecov.yml with flags * Update readme.md * chore: Update GitHub Actions workflow for test and coverage * chore: Update GitHub Actions workflow for test and coverage * Update bundle nameand add component management * Update codecov.yml with flags * chore: Remove unused @codecov/vite-plugin from package.json and vite.config.ts * chore: Update codecov.yml with flags * Fix security issues * chore: Update ReactDOM.createRoot to use type assertion
1 parent 4b8e527 commit f424608

21 files changed

+69
-62
lines changed

README.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@
1313
[![Issues][issues-shield]][issues-url]
1414
[![Pull Requests][pulls-shield]][pulls-url]
1515
[![Contributors][contributors-shield]][contributors-url]
16-
[![MIT License][license-shield]][license-url]
16+
[![License][license-shield]][license-url]
1717

1818

1919
## Continuous Integration Status
2020

21-
[![codecov](https://codecov.io/gh/clchinkc/SecureEncoder/branch/main/graph/badge.svg)](https://codecov.io/gh/clchinkc/SecureEncoder)
22-
[![CodeQL](https://github.com/clchinkc/SecureEncoder/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/clchinkc/SecureEncoder/actions/workflows/codeql-analysis.yml)
23-
[![CI](https://github.com/clchinkc/SecureEncoder/actions/workflows/test-and-converage.yml/badge.svg)](https://github.com/clchinkc/SecureEncoder/actions/workflows/test-and-converage.yml)
24-
<!-- [![Codacy Badge](https://app.codacy.com/project/badge/Grade/c4b6335acf254697b80714b81e8154d7)](https://www.codacy.com/gh/LongmaoTeamTf/deep_recommenders/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=LongmaoTeamTf/deep_recommenders&amp;utm_campaign=Badge_Grade) -->
21+
[![Codecov][codecov-shield]][codecov-url]
22+
[![Codacy][codacy-shield]][codacy-url]
23+
[![CodeQL][codeql-shield]][codeql-url]
24+
[![CI][ci-shield]][ci-url]
2525

2626

2727
## Supported Languages
2828

29-
[![Python](https://img.shields.io/badge/python-3.9_|_3.10-3572A5)](requirements.txt)
30-
[![Typescript](https://img.shields.io/badge/typescript-^5.4.5-3178c6)](requirements.txt)
29+
[![Python](https://img.shields.io/badge/python-3.9_|_3.10-3572A5)](SecureEncoderFlask\requirements.txt)
30+
[![Typescript](https://img.shields.io/badge/typescript-^5.4.5-3178c6)](SecureEncoderReact\package.json)
3131

3232
## Introduction
3333
**Secure Encoder** is a web application designed for encoding and decoding text using various cryptographic algorithms. It supports operations such as Base64, Hex, UTF-8, Latin-1, ASCII, and URL encoding/decoding, alongside encryption and decryption using AES and RSA algorithms. The primary goal is to offer a user-friendly interface for secure text manipulation, making it particularly useful for developers and security professionals.
@@ -168,19 +168,30 @@ docker-compose down
168168

169169
<!-- links -->
170170
[your-project-path]: clchinkc/SecureEncoder
171-
[follow-shield]: https://img.shields.io/github/followers/clchinkc.svg?style=flat-square
172-
[follow-url]: https://github.com/clchinkc
173-
[contributors-shield]: https://img.shields.io/github/contributors/clchinkc/SecureEncoder.svg?style=flat-square
174-
[contributors-url]: https://github.com/clchinkc/SecureEncoder/graphs/contributors
175-
[forks-shield]: https://img.shields.io/github/forks/clchinkc/SecureEncoder.svg?style=flat-square
176-
[forks-url]: https://github.com/clchinkc/SecureEncoder/network/members
177171
[stars-shield]: https://img.shields.io/github/stars/clchinkc/SecureEncoder.svg?style=flat-square
178172
[stars-url]: https://github.com/clchinkc/SecureEncoder/stargazers
173+
[forks-shield]: https://img.shields.io/github/forks/clchinkc/SecureEncoder.svg?style=flat-square
174+
[forks-url]: https://github.com/clchinkc/SecureEncoder/network/members
175+
[follow-shield]: https://img.shields.io/github/followers/clchinkc.svg?style=flat-square
176+
[follow-url]: https://github.com/clchinkc
177+
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
178+
[linkedin-url]: https://linkedin.com/in/clchinkc
179+
179180
[issues-shield]: https://img.shields.io/github/issues/clchinkc/SecureEncoder.svg?style=flat-square
180181
[issues-url]: https://img.shields.io/github/issues/clchinkc/SecureEncoder.svg
181182
[pulls-shield]: https://img.shields.io/github/issues-pr/clchinkc/SecureEncoder
182183
[pulls-url]: https://img.shields.io/github/issues-pr/clchinkc/SecureEncoder
184+
[contributors-shield]: https://img.shields.io/github/contributors/clchinkc/SecureEncoder.svg?style=flat-square
185+
[contributors-url]: https://github.com/clchinkc/SecureEncoder/graphs/contributors
183186
[license-shield]: https://img.shields.io/github/license/clchinkc/SecureEncoder.svg?style=flat-square
184187
[license-url]: https://github.com/clchinkc/SecureEncoder/blob/master/LICENSE.txt
185-
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
186-
[linkedin-url]: https://linkedin.com/in/clchinkc
188+
189+
[codecov-shield]: https://codecov.io/gh/clchinkc/SecureEncoder/branch/main/graph/badge.svg
190+
[codecov-url]: https://codecov.io/gh/clchinkc/SecureEncoder
191+
[codacy-shield]: https://app.codacy.com/project/badge/Grade/9b63875ab1164fc2a2a8a774c95399aa
192+
[codacy-url]: https://app.codacy.com/gh/clchinkc/SecureEncoder/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
193+
[codeql-shield]: https://github.com/clchinkc/SecureEncoder/actions/workflows/codeql-analysis.yml/badge.svg
194+
[codeql-url]: https://github.com/clchinkc/SecureEncoder/actions/workflows/codeql-analysis.yml
195+
[ci-shield]: https://github.com/clchinkc/SecureEncoder/actions/workflows/test-and-converage.yml/badge.svg
196+
[ci-url]: https://github.com/clchinkc/SecureEncoder/actions/workflows/test-and-converage.yml
197+

SecureEncoderFlask/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python
1+
FROM python:3.9-slim-buster
22

33
WORKDIR /src
44

SecureEncoderFlask/src/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def page_not_found(e: HTTPException):
6464
def main():
6565
if app.config["FLASK_DEVELOPMENT"]:
6666
app.run(
67-
host="0.0.0.0",
6867
port=int(app.config["FLASK_PORT"]),
6968
debug=app.config["FLASK_DEBUG"],
7069
use_reloader=True,
@@ -75,7 +74,6 @@ def main():
7574

7675
serve(
7776
app=app,
78-
host="0.0.0.0",
7977
port=int(app.config["FLASK_PORT"]),
8078
url_scheme="https",
8179
)

SecureEncoderFlask/src/compression_decompression.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66

77
def encode_number(n: int) -> list:
88
"""Encode a number using a simpler variable-length encoding."""
9-
bytes: list = []
9+
encoded: list = []
1010
while n > 127:
11-
bytes.insert(0, (n & 0x7F) | 0x80)
11+
encoded.insert(0, (n & 0x7F) | 0x80)
1212
n >>= 7
13-
bytes.insert(0, n & 0x7F)
14-
return bytes
13+
encoded.insert(0, n & 0x7F)
14+
return encoded
1515

1616

1717
def lz77_compress(text: str, window_size: int = 100, min_match_length: int = 3) -> str:

SecureEncoderReact/src/components/Alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { ReactNode, FC } from "react"
44

5-
type AlertProps = {
5+
interface AlertProps {
66
type: "alert-info" | "alert-success" | "alert-danger" | null
77
children: ReactNode
88
}

SecureEncoderReact/src/components/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { forwardRef, MouseEventHandler, ReactNode } from "react"
44

5-
type ButtonProps = {
5+
interface ButtonProps {
66
onClick?: MouseEventHandler<HTMLButtonElement>
77
children: ReactNode
88
type?: "button-primary" | "button-secondary" | null

SecureEncoderReact/src/components/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { Suspense, ReactNode, FC } from "react"
44
import Loading from "./Loading"
55

6-
type CardProps = {
6+
interface CardProps {
77
fallback?: ReactNode
88
children: ReactNode
99
}

SecureEncoderReact/src/components/ErrorBoundary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import { Component, ErrorInfo, ReactNode } from "react"
44

5-
type ErrorBoundaryProps = {
5+
interface ErrorBoundaryProps {
66
children: ReactNode
77
}
88

9-
type ErrorBoundaryState = {
9+
interface ErrorBoundaryState {
1010
hasError: boolean
1111
}
1212

SecureEncoderReact/src/components/FileList.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const FileList: FC = () => {
5858
data: files,
5959
error,
6060
isLoading,
61-
} = useQuery<string[], Error>({
61+
} = useQuery<string[]>({
6262
queryKey: ["files"],
6363
queryFn: fetchFiles,
6464
staleTime: 30000, // 30 seconds
@@ -94,8 +94,8 @@ const FileList: FC = () => {
9494
},
9595
})
9696

97-
const handleDownload = (filename: string) => downloadMutation.mutate(filename)
98-
const handleDelete = (filename: string) => deleteMutation.mutate(filename)
97+
const handleDownload = (filename: string) => { downloadMutation.mutate(filename); }
98+
const handleDelete = (filename: string) => { deleteMutation.mutate(filename); }
9999

100100
// Event listener for mouse click to auto-hide the notification
101101
useEffect(() => {
@@ -139,15 +139,15 @@ const FileList: FC = () => {
139139
type="button-primary"
140140
outline
141141
className="w-1/2"
142-
onClick={() => handleDownload(file)}
142+
onClick={() => { handleDownload(file); }}
143143
>
144144
Download
145145
</Button>
146146
<Button
147147
type="button-secondary"
148148
outline
149149
className="w-1/2"
150-
onClick={() => handleDelete(file)}
150+
onClick={() => { handleDelete(file); }}
151151
>
152152
Delete
153153
</Button>

SecureEncoderReact/src/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import small_logo from "../assets/android-chrome-192x192.png"
55
import big_logo from "../assets/android-chrome-512x512.png"
66
import ToggleButton from "./ToggleButton"
77

8-
type HeaderProps = {
8+
interface HeaderProps {
99
title: string
1010
children: ReactNode
1111
}

SecureEncoderReact/src/components/KeyUploader.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Alert from "./Alert"
66
import { useMutation, useQueryClient } from "@tanstack/react-query"
77
import Card from "./Card"
88

9-
type KeyUploaderProps = {
9+
interface KeyUploaderProps {
1010
uploadButtonRef: RefObject<HTMLButtonElement>
1111
fileSelectionRef: RefObject<HTMLInputElement>
1212
}
@@ -39,7 +39,7 @@ const KeyUploader: FC<KeyUploaderProps> = ({ uploadButtonRef, fileSelectionRef }
3939
onSuccess: (filename) => {
4040
setMessage(`File ${filename} uploaded successfully!`)
4141
setAlertType("alert-success")
42-
queryClient.invalidateQueries({ queryKey: ["files"] })
42+
void queryClient.invalidateQueries({ queryKey: ["files"] })
4343
},
4444
onError: (error) => {
4545
setMessage(`Error: ${error.message}`)

SecureEncoderReact/src/components/OperationSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { RefObject, FC } from "react"
44
import { useAppContext } from "../context/AppContext"
55
import Card from "./Card"
66

7-
type OperationSelectorProps = {
7+
interface OperationSelectorProps {
88
chooseButtonRef: RefObject<HTMLSelectElement>
99
}
1010

SecureEncoderReact/src/components/ResultDisplay.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Button from "./Button"
66
import Alert from "./Alert"
77
import Card from "./Card"
88

9-
type ResultDisplayProps = {
9+
interface ResultDisplayProps {
1010
copyToClipboardRef: RefObject<HTMLButtonElement>
1111
downloadFileRef: RefObject<HTMLButtonElement>
1212
}
@@ -30,7 +30,7 @@ const ResultDisplay: FC<ResultDisplayProps> = ({ copyToClipboardRef, downloadFil
3030
}
3131
}
3232

33-
const handleDownload = async () => {
33+
const handleDownload = () => {
3434
if (!result) return
3535
try {
3636
const file = new Blob([result], { type: "text/plain" })

SecureEncoderReact/src/components/Tabs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { FC } from "react"
44
import { useAppContext } from "../context/AppContext"
55

6-
type Option = {
6+
interface Option {
77
title: string
88
value: string
99
}
@@ -34,7 +34,7 @@ const Tabs: FC = () => {
3434
<h2 className="sr-only">Operation Tabs</h2>
3535
{options.map((option) => (
3636
<div
37-
onClick={() => setOperation(option.value)}
37+
onClick={() => { setOperation(option.value); }}
3838
className={`w-full rounded-t-xl border-2 p-1 px-3 ${
3939
operation === option.value
4040
? "bg-neutral-100 text-neutral-700 dark:bg-neutral-700 dark:text-neutral-100"

SecureEncoderReact/src/components/TextProcessor.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Card from "./Card"
88
import { useMutation } from "@tanstack/react-query"
99
import { throttle, debounce } from "../utils/throttleAndDebounce"
1010

11-
type TextProcessorProps = {
11+
interface TextProcessorProps {
1212
encodingButtonRef: RefObject<HTMLButtonElement>
1313
decodingButtonRef: RefObject<HTMLButtonElement>
1414
}
@@ -149,8 +149,8 @@ const TextProcessor: FC<TextProcessorProps> = ({ encodingButtonRef, decodingButt
149149
className="form overflow-y-auto"
150150
id="text"
151151
value={text}
152-
onChange={(e) => setText(e.target.value)}
153-
onBlur={() => handleImmediateSave()}
152+
onChange={(e) => { setText(e.target.value); }}
153+
onBlur={() => { handleImmediateSave(); }}
154154
placeholder="Enter text here"
155155
rows={1}
156156
aria-label="Input text"
@@ -165,7 +165,7 @@ const TextProcessor: FC<TextProcessorProps> = ({ encodingButtonRef, decodingButt
165165
type="button-primary"
166166
className="w-full"
167167
disabled={!text.trim() || !operation || loading}
168-
onClick={(e) => handleSubmit("encode", e)}
168+
onClick={(e) => { handleSubmit("encode", e); }}
169169
showAlert={showMessage}
170170
>
171171
{loading && action === "encode" ? "Encoding..." : "Encode / Encrypt"}
@@ -177,7 +177,7 @@ const TextProcessor: FC<TextProcessorProps> = ({ encodingButtonRef, decodingButt
177177
type="button-secondary"
178178
className="w-full"
179179
disabled={!text.trim() || !operation || loading}
180-
onClick={(e) => handleSubmit("decode", e)}
180+
onClick={(e) => { handleSubmit("decode", e); }}
181181
showAlert={showMessage}
182182
>
183183
{loading && action === "decode" ? "Decoding..." : "Decode / Decrypt"}

SecureEncoderReact/src/components/ToggleButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const ToggleButton: FC = () => {
3232
/>
3333
<label className="relative cursor-pointer p-2" htmlFor="light-switch">
3434
<svg
35-
className={`${darkMode ? "hidden" : "block"}`}
35+
className={darkMode ? "hidden" : "block"}
3636
width="16"
3737
height="16"
3838
xmlns="http://www.w3.org/2000/svg"
@@ -47,7 +47,7 @@ const ToggleButton: FC = () => {
4747
/>
4848
</svg>
4949
<svg
50-
className={`${darkMode ? "block" : "hidden"}`}
50+
className={darkMode ? "hidden" : "block"}
5151
width="16"
5252
height="16"
5353
xmlns="http://www.w3.org/2000/svg"

SecureEncoderReact/src/context/AppContext.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
SetStateAction,
1313
} from "react"
1414

15-
type AppContextProps = {
15+
interface AppContextProps {
1616
files: string[]
1717
setFiles: Dispatch<SetStateAction<string[]>>
1818
result: string
@@ -37,7 +37,7 @@ export const useAppContext = (): AppContextProps => {
3737
return context
3838
}
3939

40-
type AppContextProviderProps = {
40+
interface AppContextProviderProps {
4141
children: ReactNode
4242
value?: Partial<AppContextProps>
4343
}
@@ -57,19 +57,19 @@ export const AppContextProvider: FC<AppContextProviderProps> = ({
5757
}
5858

5959
const [files, setFiles] = useState<string[]>(
60-
value?.files || getSessionStorageItemArray("files")
60+
value?.files ?? getSessionStorageItemArray("files")
6161
)
6262
const [result, setResult] = useState<string>(
63-
value?.result || getSessionStorageItem("result", "")
63+
value?.result ?? getSessionStorageItem("result", "")
6464
)
6565
const [operation, setOperation] = useState<string>(
66-
value?.operation || getSessionStorageItem("operation", "")
66+
value?.operation ?? getSessionStorageItem("operation", "")
6767
)
6868
const [action, setAction] = useState<string>(
69-
value?.action || getSessionStorageItem("action", "")
69+
value?.action ?? getSessionStorageItem("action", "")
7070
)
71-
const [text, setText] = useState<string>(value?.text || getSessionStorageItem("text", ""))
72-
const [loading, setLoading] = useState<boolean>(value?.loading || false)
71+
const [text, setText] = useState<string>(value?.text ?? getSessionStorageItem("text", ""))
72+
const [loading, setLoading] = useState<boolean>(value?.loading ?? false)
7373

7474
useEffect(() => {
7575
sessionStorage.setItem("files", JSON.stringify(files))

SecureEncoderReact/src/hoc/withKeyboardShortcuts.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useEffect, useRef, useState, RefObject, ComponentType, FC } from "react"
44

5-
type RefProps = {
5+
interface RefProps {
66
uploadButtonRef: RefObject<HTMLButtonElement>
77
fileSelectionRef: RefObject<HTMLInputElement>
88
chooseButtonRef: RefObject<HTMLSelectElement>

SecureEncoderReact/src/pages/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import withKeyboardShortcuts from "../hoc/withKeyboardShortcuts"
1717
import "../tailwind.css"
1818
import "../App.css"
1919

20-
type AppProps = {
20+
interface AppProps {
2121
uploadButtonRef: RefObject<HTMLButtonElement>
2222
fileSelectionRef: RefObject<HTMLInputElement>
2323
chooseButtonRef: RefObject<HTMLSelectElement>

SecureEncoderReact/src/utils/throttleAndDebounce.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ export const throttle = <T extends unknown[]>(func: Procedure<T>, delay: number)
1010
return
1111
}
1212
lastCall = now
13-
return func(...args)
13+
func(...args)
1414
}
1515
}
1616

1717
export const debounce = <T extends unknown[]>(func: Procedure<T>, delay: number) => {
1818
let timeoutId: NodeJS.Timeout
1919
return function (...args: T) {
20-
if (timeoutId) {
21-
clearTimeout(timeoutId)
22-
}
20+
clearTimeout(timeoutId)
2321
timeoutId = setTimeout(() => {
2422
func(...args)
2523
}, delay)

0 commit comments

Comments
 (0)