Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/update-dikt…
Browse files Browse the repository at this point in the history
…at-analysis.yml
  • Loading branch information
nulls committed Nov 30, 2023
2 parents d08fd1e + 7a7e833 commit d7a5655
Show file tree
Hide file tree
Showing 319 changed files with 20,565 additions and 313 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
'save-backend',
'save-orchestrator',
'save-frontend',
'save-cosv-frontend',
'save-preprocessor',
'test-utils',
'save-api',
Expand Down
23 changes: 23 additions & 0 deletions .run/Cosv-Frontend-LocalRun.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Cosv-Frontend-LocalRun" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--continuous" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="save-cosv-frontend:run" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Names that are used as endpoints in the frontend.
* If you create a new view with new URL - add it here.
*/

package com.saveourtool.save.validation

import com.saveourtool.save.utils.URL_PATH_DELIMITER
import kotlin.js.JsExport

/**
* @property path substring of url that defines given route
*/
@JsExport
enum class FrontendCosvRoutes(val path: String) {
ABOUT_US("about"),
BAN("ban"),
COOKIE("cookie"),
ERROR_404("404"),
MANAGE_ORGANIZATIONS("organizations"),
NOT_FOUND("not-found"),
PROFILE("profile"),
REGISTRATION("registration"),
SETTINGS_DELETE("$SETTINGS/delete"),
SETTINGS_EMAIL("$SETTINGS/email"),
SETTINGS_ORGANIZATIONS("$SETTINGS/organizations"),
SETTINGS_PROFILE("$SETTINGS/profile"),
SETTINGS_TOKEN("$SETTINGS/token"),
TERMS_OF_USE("terms-of-use"),
THANKS_FOR_REGISTRATION("thanks-for-registration"),
VULN("vuln"),
VULNERABILITIES("$VULN/list"),
VULNERABILITY_SINGLE("$VULN/collection"),
VULN_COSV_SCHEMA("$VULN/schema"),
VULN_CREATE("$VULN/create-vulnerability"),
VULN_TOP_RATING("$VULN/top-rating"),
VULN_UPLOAD("$VULN/upload-vulnerability"),
;

override fun toString(): String = path

companion object {
/**
* List of views on which topbar should not be rendered
*/
val noTopBarViewList = arrayOf(
REGISTRATION,
ERROR_404,
TERMS_OF_USE,
THANKS_FOR_REGISTRATION,
)

/**
* Get forbidden words from [FrontendCosvRoutes].
*
* @return list of forbidden words
*/
fun getForbiddenWords() = FrontendCosvRoutes.values()
.map { it.path.split(URL_PATH_DELIMITER) }
.flatten()
.toTypedArray()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum class FrontendRoutes(val path: String) {
INDEX(""),
MANAGE_ORGANIZATIONS("organizations"),
NOT_FOUND("not-found"),
PROFILE("profile"),
PROJECTS("projects"),
REGISTRATION("registration"),
SANDBOX("sandbox"),
Expand All @@ -41,14 +42,6 @@ enum class FrontendRoutes(val path: String) {
SETTINGS_TOKEN("$SETTINGS/token"),
TERMS_OF_USE("terms-of-use"),
THANKS_FOR_REGISTRATION("thanks-for-registration"),
VULN("vuln"),
VULNERABILITIES("$VULN/list"),
VULNERABILITY_SINGLE("$VULN/collection"),
VULN_COSV_SCHEMA("$VULN/schema"),
VULN_CREATE("$VULN/create-vulnerability"),
VULN_PROFILE("$VULN/profile"),
VULN_TOP_RATING("$VULN/top-rating"),
VULN_UPLOAD("$VULN/upload-vulnerability"),
;

override fun toString(): String = path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private fun String.hasOnlyAlphaNumOrAllowedSpecialSymbols(
allowedSpecialSymbols: Set<Char> = namingAllowedSpecialSymbols
) = all { it.isLetterOrDigit() || allowedSpecialSymbols.contains(it) }

private fun String.containsForbiddenWords() = (FrontendRoutes.getForbiddenWords() + BackendRoutes.getForbiddenWords())
private fun String.containsForbiddenWords() = (FrontendRoutes.getForbiddenWords() + FrontendCosvRoutes.getForbiddenWords() + BackendRoutes.getForbiddenWords())
.any { this == it }

private fun String.isLengthOk(allowedLength: Int) = length <= allowedLength
16 changes: 16 additions & 0 deletions save-cosv-frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# COSV Frontend

### Building
* For IR usage see https://github.com/JetBrains/kotlin-wrappers#experimental-ir-backend

To run frontend locally, use `./gradlew :save-cosv-frontend:browserDevelopmentRun --continuous` or `./gradlew :save-cosv-frontend:browserProductionRun --continuous`.

To pack distribution, use `./gradlew :save-cosv-frontend:browserDevelopmentWebpack` and `./gradlew :save-cosv-frontend:browserProductionWebpack`.

save-backend consumes frontend distribution as a dependency. Frontend distribution is copied and included in spring boot resources.

### `nginx` [configuration](../save-frontend-common/README.md)

### `webpack-dev-server` [configuration for no `api-gateway` run](../save-frontend-common/README.md)

### [Using OAuth with a local deployment (`api-gateway` on)](../save-frontend-common/README.md)
Loading

0 comments on commit d7a5655

Please sign in to comment.