Skip to content

Commit 30bd404

Browse files
committed
First commit
1 parent b8b569b commit 30bd404

Some content is hidden

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

56 files changed

+9192
-2
lines changed

.github/workflows/codeql.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: "CodeQL Advanced"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'core/**'
8+
- 'resource/**'
9+
- 'App.xaml'
10+
- 'App.xaml.cs'
11+
- 'MainWindow.xaml'
12+
- 'MainWindow.xaml.cs'
13+
- 'Program.cs'
14+
- 'Yama.dll'
15+
- 'install.bat'
16+
- 'YAMAGoya.csproj'
17+
- '.github/workflows/codeql.yml'
18+
pull_request:
19+
branches: [ "main" ]
20+
paths:
21+
- 'core/**'
22+
- 'resource/**'
23+
- 'App.xaml'
24+
- 'App.xaml.cs'
25+
- 'MainWindow.xaml'
26+
- 'MainWindow.xaml.cs'
27+
- 'Program.cs'
28+
- 'Yama.dll'
29+
- 'install.bat'
30+
- 'YAMAGoya.csproj'
31+
- '.github/workflows/codeql.yml'
32+
schedule:
33+
- cron: '0 2 * * 1'
34+
35+
jobs:
36+
analyze:
37+
name: Analyze
38+
runs-on: windows-latest
39+
timeout-minutes: 360
40+
permissions:
41+
actions: read
42+
contents: read
43+
security-events: write
44+
45+
strategy:
46+
fail-fast: false
47+
matrix:
48+
language: [ 'csharp' ]
49+
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
54+
- name: Setup .NET
55+
uses: actions/setup-dotnet@v4
56+
with:
57+
dotnet-version: '9.0.x'
58+
59+
- name: Initialize CodeQL
60+
uses: github/codeql-action/init@v3
61+
with:
62+
languages: ${{ matrix.language }}
63+
64+
- name: Restore dependencies
65+
run: dotnet restore
66+
67+
- name: Build
68+
run: dotnet build --configuration Release -r win-x64 --no-restore
69+
70+
- name: Perform CodeQL Analysis
71+
uses: github/codeql-action/analyze@v3
72+
with:
73+
category: "/language:${{matrix.language}}"

.github/workflows/test.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'core/**'
8+
- 'resource/**'
9+
- 'App.xaml'
10+
- 'App.xaml.cs'
11+
- 'MainWindow.xaml'
12+
- 'MainWindow.xaml.cs'
13+
- 'Program.cs'
14+
- 'Yama.dll'
15+
- 'install.bat'
16+
- 'YAMAGoya.csproj'
17+
- '.github/workflows/test.yml'
18+
pull_request:
19+
branches: [ "main" ]
20+
paths:
21+
- 'core/**'
22+
- 'resource/**'
23+
- 'App.xaml'
24+
- 'App.xaml.cs'
25+
- 'MainWindow.xaml'
26+
- 'MainWindow.xaml.cs'
27+
- 'Program.cs'
28+
- 'Yama.dll'
29+
- 'install.bat'
30+
- 'YAMAGoya.csproj'
31+
- '.github/workflows/test.yml'
32+
33+
jobs:
34+
build-and-test:
35+
runs-on: windows-latest
36+
permissions:
37+
contents: read
38+
actions: write
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Setup .NET
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: '9.0.x'
47+
48+
- name: Restore dependencies
49+
run: dotnet restore
50+
51+
- name: Build
52+
run: dotnet build --configuration Release -r win-x64 --no-restore
53+
54+
- name: Test
55+
run: dotnet test --configuration Release -r win-x64 --no-build
56+
57+
- name: Test session
58+
run: dotnet run -- -s
59+
60+
- name: Test detection
61+
run: dotnet run -- -d rules -a --verbose
62+
timeout-minutes: 1
63+
continue-on-error: true
64+
65+
- name: Test release
66+
run: dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=false -o out
67+
continue-on-error: true
68+
69+
- name: zip build artifacts
70+
run: Compress-Archive -Path out/* -DestinationPath yamagoya.zip -Force
71+
72+
- name: Upload artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: yamagoya
76+
path: yamagoya.zip

App.xaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Application x:Class="YAMAGoya.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
5+
xmlns:local="clr-namespace:YAMAGoya">
6+
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<ResourceDictionary.MergedDictionaries>
10+
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Indigo" SecondaryColor="DeepPurple" />
11+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesign2.Defaults.xaml" />
12+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Indigo.xaml" />
13+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Secondary/MaterialDesignColor.DeepPurple.xaml" />
14+
</ResourceDictionary.MergedDictionaries>
15+
</ResourceDictionary>
16+
</Application.Resources>
17+
</Application>

App.xaml.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using System;
2+
using System.Windows;
3+
using System.Runtime.InteropServices;
4+
using System.Diagnostics.CodeAnalysis;
5+
using Application = System.Windows.Application;
6+
using MessageBox = System.Windows.MessageBox;
7+
8+
namespace YAMAGoya
9+
{
10+
/// <summary>
11+
/// Interaction logic for App.xaml.
12+
/// This class serves as the entry point of the application.
13+
/// It determines whether to run in GUI mode or command-line mode based on startup arguments.
14+
/// </summary>
15+
[SuppressMessage("Design", "CA1515:Type can be made internal", Justification = "App must be public for XAML binding to work properly.")]
16+
public partial class App : Application
17+
{
18+
/// <summary>
19+
/// Gets or sets a value indicating whether the application is running in GUI mode.
20+
/// When command-line arguments are provided, this property remains false.
21+
/// </summary>
22+
public static bool IsGuiMode { get; set; }
23+
24+
/// <summary>
25+
/// Attaches the calling process to the console of an existing process.
26+
/// Pass -1 to attach to the parent process's console.
27+
/// </summary>
28+
/// <param name="processId">The process ID to attach to.</param>
29+
/// <returns>True if successful; otherwise, false.</returns>
30+
[DllImport("Kernel32.dll")]
31+
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
32+
private static extern bool AttachConsole(int processId);
33+
34+
/// <summary>
35+
/// Static constructor. Attempts to attach the process to the parent's console.
36+
/// </summary>
37+
static App()
38+
{
39+
AttachConsole(-1);
40+
}
41+
42+
/// <summary>
43+
/// Called when the application starts.
44+
/// If command-line arguments are provided, the application runs in command-line mode.
45+
/// Otherwise, it launches the GUI.
46+
/// </summary>
47+
/// <param name="e">Startup event arguments.</param>
48+
protected override void OnStartup(StartupEventArgs e)
49+
{
50+
// Ensure that the StartupEventArgs is not null.
51+
ArgumentNullException.ThrowIfNull(e);
52+
53+
base.OnStartup(e);
54+
55+
// If command-line arguments are provided, run in command-line mode.
56+
if (e.Args != null && e.Args.Length > 0)
57+
{
58+
Console.WriteLine("Running in command-line mode...");
59+
try
60+
{
61+
CommandLineProcessor.Process(e.Args);
62+
}
63+
catch (ArgumentException ex)
64+
{
65+
MessageBox.Show($"Argument error: {ex.Message}", "YAMAGoya Error", MessageBoxButton.OK, MessageBoxImage.Error);
66+
}
67+
catch (InvalidOperationException ex)
68+
{
69+
MessageBox.Show($"Operation error: {ex.Message}", "YAMAGoya Error", MessageBoxButton.OK, MessageBoxImage.Error);
70+
}
71+
// Rethrow any other exceptions.
72+
catch
73+
{
74+
MessageBox.Show("An unexpected error occurred. Please check the logs for more details.", "YAMAGoya Error", MessageBoxButton.OK, MessageBoxImage.Error);
75+
throw;
76+
}
77+
Shutdown();
78+
}
79+
else
80+
{
81+
IsGuiMode = true;
82+
MainWindow mainWindow = new MainWindow();
83+
mainWindow.Show();
84+
}
85+
}
86+
}
87+
}

LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The 3-Clause BSD License
2+
3+
SPDX short identifier: BSD-3-Clause
4+
Note: This license has also been called the "New BSD License" or "Modified BSD License". See also the 2-clause BSD License.
5+
6+
---
7+
8+
Copyright 2025 JPCERT Coordination Center
9+
10+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
11+
12+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
13+
14+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
15+
16+
3. Neither JPCERT Coordination Center nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19+
20+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)