Skip to content

Commit

Permalink
Make code snippet visibility configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Mar 8, 2021
1 parent a585101 commit 20f05c7
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ challenges:
type: boolean
showMitigations:
type: boolean
showCodeSnippets:
type: string
restrictToTutorialsFirst:
type: boolean
overwriteUrlForProductTamperingChallenge:
Expand Down
1 change: 1 addition & 0 deletions config/ctf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ application:
showOnFirstStart: false
challenges:
showHints: false
showCodeSnippets: solved
safetyOverride: true
hackingInstructor:
isEnabled: false
Expand Down
1 change: 1 addition & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ challenges:
showSolvedNotifications: true
showHints: true
showMitigations: true
showCodeSnippets: always # Options: never solved always
restrictToTutorialsFirst: false
overwriteUrlForProductTamperingChallenge: 'https://owasp.slack.com'
xssBonusPayload: '<iframe width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/771984076&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true"></iframe>'
Expand Down
1 change: 1 addition & 0 deletions config/fbctf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ application:
showOnFirstStart: false
challenges:
showHints: false
showCodeSnippets: solved
hackingInstructor:
isEnabled: false
ctf:
Expand Down
1 change: 1 addition & 0 deletions config/mozilla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ application:
encryption: ~
challenges:
showHints: false
showCodeSnippets: never
xssBonusPayload: '<iframe width="560" height="315" src="https://www.youtube.com/embed/0u9g0LhRkGk" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
hackingInstructor:
isEnabled: false
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/Services/configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface Config {
showSolvedNotifications: boolean
showHints: boolean
showMitigations: boolean
showCodeSnippets: string
restrictToTutorialsFirst: boolean
safetyOverride: boolean
overwriteUrlForProductTamperingChallenge: string
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/score-board/score-board.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
</button>
</a>
<button
*ngIf="challenge.hasSnippet"
*ngIf="challenge.hasSnippet && (showCodeSnippets === 'always' || showCodeSnippets === 'solved' && challenge.solved)"
mat-mini-fab color="primary"
(click)="showCodeSnippet(challenge.key)"
[matTooltip]="('INFO_VULNERABLE_CODE_SNIPPET' | translate)"
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/score-board/score-board.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export class ScoreBoardComponent implements OnInit {
public allowRepeatNotifications: boolean = false
public showChallengeHints: boolean = true
public showVulnerabilityMitigations: boolean = true
public showCodeSnippets: string = 'solved'
public showHackingInstructor: boolean = true
public challenges: Challenge[] = []
public percentChallengesSolved: string = '0'
Expand All @@ -75,6 +76,7 @@ export class ScoreBoardComponent implements OnInit {
this.allowRepeatNotifications = config.challenges.showSolvedNotifications && config.ctf?.showFlagsInNotifications
this.showChallengeHints = config.challenges.showHints
this.showVulnerabilityMitigations = config.challenges.showMitigations
this.showCodeSnippets = config.challenges.showCodeSnippets
this.showHackingInstructor = config.hackingInstructor?.isEnabled
this.showContributionInfoBox = config.application.showGitHubLinks
this.questionnaireUrl = config.application.social?.questionnaireUrl
Expand Down

0 comments on commit 20f05c7

Please sign in to comment.