Skip to content

Commit 9c23a10

Browse files
committed
merge: Merge branch 'develop' into feature/more_hardening
Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com> # Conflicts: # meson.build # utils/C/openSeaChest/openSeaChest_Defect.c # utils/C/openSeaChest/openSeaChest_PowerControl.c
2 parents 8d15e28 + 2db1972 commit 9c23a10

6 files changed

Lines changed: 105 additions & 34 deletions

File tree

.github/workflows/meson.yml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: CI for meson build
44
on:
55
push:
66
branches: [ develop, master, release/*, feature/*, hotfix/* ]
7-
tags: [ v* ]
7+
tags: [ v*, test-ci* ]
88
pull_request:
99
branches: [ develop ]
1010

@@ -223,7 +223,35 @@ jobs:
223223
if: startsWith(matrix.config.name, 'Windows Clang')
224224
run: |
225225
$headers = @{ Authorization = 'Bearer ${{ secrets.GITHUB_TOKEN }}' }
226-
echo "LLVM_RELID=$((Invoke-WebRequest -Headers $headers 'https://api.github.com/repos/llvm/llvm-project/releases/latest').Content | ConvertFrom-Json | Select-Object -ExpandProperty id)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
226+
$latestRelease = Invoke-WebRequest -Headers $headers 'https://api.github.com/repos/llvm/llvm-project/releases/latest'
227+
$releaseData = $latestRelease.Content | ConvertFrom-Json
228+
$assets = $releaseData.assets | Where-Object { $_.name -like "*win64.exe" }
229+
230+
if ($assets) {
231+
$downloadUrl = $assets.browser_download_url
232+
echo "LLVM_RELID=$($releaseData.id)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
233+
echo "LLVM_DOWNLOAD_URL=$downloadUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
234+
} else {
235+
Write-Host "No current Windows build available for the latest release. Searching for previous releases..."
236+
$releases = Invoke-WebRequest -Headers $headers 'https://api.github.com/repos/llvm/llvm-project/releases'
237+
$found = $false
238+
239+
foreach ($release in $releases.Content | ConvertFrom-Json) {
240+
$assets = $release.assets | Where-Object { $_.name -like "*win64.exe" }
241+
if ($assets) {
242+
$downloadUrl = $assets.browser_download_url
243+
echo "LLVM_RELID=$($release.id)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
244+
echo "LLVM_DOWNLOAD_URL=$downloadUrl" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
245+
$found = $true
246+
break
247+
}
248+
}
249+
250+
if (-not $found) {
251+
Write-Host "No Windows build available for any recent releases."
252+
exit 0
253+
}
254+
}
227255
228256
- name: Restore LLVM from cache
229257
if: startsWith(matrix.config.name, 'Windows Clang')
@@ -260,14 +288,6 @@ jobs:
260288
meson setup build -Dprefix=/ -Dmandir=/man -Dbindir=/ ${{ matrix.config.meson_opts }} --buildtype=release
261289
meson install -C build
262290
263-
- name: Packing release
264-
env:
265-
ARCHIVE_EXT: ${{ matrix.config.release_extension }}
266-
run: |
267-
cd build
268-
${{ matrix.config.archive_command }} "${DESTDIR}${ARCHIVE_EXT}" $DESTDIR
269-
shell: bash
270-
271291
# add `GOBIN` to the `PATH` otherwise nfpm in next step can't be found
272292
- uses: actions/setup-go@v5
273293
if: ${{ matrix.config.create_package }}
@@ -290,6 +310,26 @@ jobs:
290310
nfpm package -f ../../nfpm.yaml -p rpm -t ..
291311
shell: bash
292312

313+
- name: Set ownership of executables to root:root
314+
if: ${{ matrix.config.os != 'windows-latest' }}
315+
run: sudo chown -R root:root build
316+
317+
- name: Packing release
318+
env:
319+
ARCHIVE_EXT: ${{ matrix.config.release_extension }}
320+
run: |
321+
cd build
322+
if [[ "${{ matrix.config.os }}" != "windows-latest" ]]; then
323+
sudo ${{ matrix.config.archive_command }} "${DESTDIR}${ARCHIVE_EXT}" $DESTDIR
324+
else
325+
${{ matrix.config.archive_command }} "${DESTDIR}${ARCHIVE_EXT}" $DESTDIR
326+
fi
327+
shell: bash
328+
329+
- name: Set ownership of tar archive to root:root
330+
if: ${{ matrix.config.os != 'windows-latest' }}
331+
run: sudo chown root:root build/"${DESTDIR}${ARCHIVE_EXT}"
332+
293333
- name: Generate Hashes
294334
if: ${{ matrix.config.publish_release }}
295335
shell: bash
@@ -314,7 +354,7 @@ jobs:
314354
build/*.rpm
315355
316356
- name: Publish release
317-
if: ${{ startsWith(github.ref, 'refs/tags/v') && matrix.config.publish_release }}
357+
if: ${{ (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/test-ci')) && matrix.config.publish_release }}
318358
uses: softprops/action-gh-release@v2
319359
with:
320360
files: |

meson.build

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ if c.get_id().contains('gcc') or c.get_id().contains('clang')
3737
'-Wundef',
3838
'-Wformat',
3939
'-Wformat=2',
40-
'-Wsign-conversion',
4140
'-Wint-conversion',#-Warith-conversion
4241
'-Wenum-conversion',
4342
'-Wfloat-conversion',
@@ -79,6 +78,11 @@ if c.get_id().contains('gcc') or c.get_id().contains('clang')
7978
'-fvisibility=hidden', #to work similarly to Window's DLL import/export
8079
]
8180

81+
if c.get_id().contains('gcc') and c.version().version_compare('>=10.0')
82+
#only enable the sign conversion warning on versions 10 and up because it is way too noisy on earlier GCC versions than it is useful-TJE
83+
warning_flags += '-Wsign-conversion'
84+
endif
85+
8286
if c.get_id().contains('gcc') and target_machine.system() == 'windows'
8387
#According to the link below, this is not needed in Windows...it also causes a bug in some versions of GCC for Windows.
8488
#https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90458
@@ -105,6 +109,15 @@ if c.get_id().contains('gcc') or c.get_id().contains('clang')
105109
'-Wl,-z,relro',
106110
'-Wl,-z,now'
107111
]
112+
fortifytest = ''' #include <stdio.h>
113+
int main() {
114+
return 0;
115+
}
116+
'''
117+
fortifyresult = c.compiles(fortifytest, name : '_FORTIFY_SOURCE override', args : ['-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=5', '-Werror'])
118+
if fortifyresult == true
119+
warning_flags += ['-U_FORTIFY_SOURCE', '-D_FORTIFY_SOURCE=3']
120+
endif
108121
elif c.get_id().contains('msvc')
109122
#See here for enabling/disabling msvc warnings:
110123
#https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170
@@ -167,7 +180,6 @@ elif c.get_id().contains('msvc')
167180
'/we4628', # digraphs not supported with -Ze. Character sequence 'digraph' not interpreted as alternate token for 'char'
168181
'/we4289', # nonstandard extension used : 'var' : loop control variable declared in the for-loop is used outside the for-loop scope
169182
'/we4464', # relative include path contains '..'
170-
'/std:c17', #NOTE: It would be better to specify for the project settings above for all compilers, but currently still supporting MSVC and GCC compilers that may not be C11 compatible.-TJE
171183
'/GS', #security cookie for stack protection
172184
'/sdl', #adds recommended security development lifecycle checks
173185
'/Qspectre',
@@ -179,6 +191,10 @@ elif c.get_id().contains('msvc')
179191
# https://learn.microsoft.com/en-us/cpp/build/reference/qintel-jcc-erratum?view=msvc-170
180192
warning_flags += '/QIntel-jcc-erratum'
181193
endif
194+
195+
if c.has_argument('/std:c17')
196+
c_std = 'c17'
197+
endif
182198

183199
linker_flags += [
184200
'/guard:cf', #control flow guard
@@ -219,9 +235,18 @@ if (c.get_id() == 'gcc' or c.get_id() == 'clang') and target_machine.system() !=
219235
#skipping sunos since this was a compatibility issue that was reported earlier. May be able to find a better way to handle this in the future.
220236
if not (target_machine.system() == 'sunos') and c.get_id().contains('gcc')
221237
if c.version().version_compare('<5.0')
222-
if c.has_argument('-std=gnu99')
238+
#4.7.4+ has C11 support, but c89 is the default standard so we need to change it.
239+
if c.has_argument('-std=gnu11')
240+
c_std = 'gnu11'
241+
if meson.version().version_compare('<1.0.0')
242+
add_project_arguments('-std=gnu11', language : 'c')
243+
endif
244+
elif c.has_argument('-std=gnu99')
223245
#Add this argument to the list since C99 is a minimum required C compiler standard
224-
add_global_arguments('-std=gnu99', language: 'c',)
246+
c_std = 'gnu99'
247+
if meson.version().version_compare('<1.0.0')
248+
add_project_arguments('-std=gnu99', language : 'c')
249+
endif
225250
else
226251
error('C99/GNU99 standard is required but was not able to be set!')
227252
endif
@@ -284,6 +309,11 @@ opensea_common_dep = opensea_common.get_variable('opensea_common_dep')
284309
opensea_transport = subproject('opensea-transport')
285310
opensea_transport_dep = opensea_transport.get_variable('opensea_transport_dep')
286311

312+
csmisupport = opensea_transport.get_variable('csmisupport')
313+
if csmisupport.enabled()
314+
add_project_arguments('-DENABLE_CSMI', language : 'c')
315+
endif
316+
287317
opensea_operations = subproject('opensea-operations')
288318
opensea_operations_dep = opensea_operations.get_variable('opensea_operations_dep')
289319

src/openseachest_util_options.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5354,7 +5354,7 @@ void print_Check_Grown_List_Help(bool shortHelp)
53545354

53555355
void print_Show_Pending_List_Help(bool shortHelp)
53565356
{
5357-
printf("\t--%s (Seagate Only)\n", SHOW_PENDING_LIST_LONG_OPT_STRING);
5357+
printf("\t--%s\n", SHOW_PENDING_LIST_LONG_OPT_STRING);
53585358
if (!shortHelp)
53595359
{
53605360
printf("\t\tUse this option to show the pending defect list\n");
@@ -5365,7 +5365,7 @@ void print_Show_Pending_List_Help(bool shortHelp)
53655365

53665366
void print_Create_Uncorrectable_Help(bool shortHelp)
53675367
{
5368-
printf("\t--%s [lba]\t(Seagate Only)\n", CREATE_UNCORRECTABLE_LONG_OPT_STRING);
5368+
printf("\t--%s [lba]\n", CREATE_UNCORRECTABLE_LONG_OPT_STRING);
53695369
if (!shortHelp)
53705370
{
53715371
printf("\t\tUse this option to create a uncorrectable error at\n");
@@ -5379,7 +5379,7 @@ void print_Create_Uncorrectable_Help(bool shortHelp)
53795379

53805380
void print_Flag_Uncorrectable_Help(bool shortHelp)
53815381
{
5382-
printf("\t--%s\t(Seagate Only)\n", FLAG_UNCORRECTABLE_LONG_OPT_STRING);
5382+
printf("\t--%s\n", FLAG_UNCORRECTABLE_LONG_OPT_STRING);
53835383
if (!shortHelp)
53845384
{
53855385
printf("\t\tUse this option to flag an uncorrectable error instead of\n");
@@ -5397,7 +5397,7 @@ void print_Flag_Uncorrectable_Help(bool shortHelp)
53975397

53985398
void print_Uncorrectable_Range_Help(bool shortHelp)
53995399
{
5400-
printf("\t--%s [range]\t(Seagate Only)\n", UNCORRECTABLE_RANGE_LONG_OPT_STRING);
5400+
printf("\t--%s [range]\n", UNCORRECTABLE_RANGE_LONG_OPT_STRING);
54015401
if (!shortHelp)
54025402
{
54035403
printf("\t\tUse this option to specify a range of LBAs to create an\n");
@@ -5410,7 +5410,7 @@ void print_Uncorrectable_Range_Help(bool shortHelp)
54105410

54115411
void print_Random_Uncorrectable_Help(bool shortHelp)
54125412
{
5413-
printf("\t--%s [number of errors]\t(Seagate Only)\n", RANDOM_UNCORRECTABLES_LONG_OPT_STRING);
5413+
printf("\t--%s [number of errors]\n", RANDOM_UNCORRECTABLES_LONG_OPT_STRING);
54145414
if (!shortHelp)
54155415
{
54165416
printf("\t\tUse this option to create a number of random uncorrectable\n");
@@ -5433,7 +5433,7 @@ void print_Disable_Read_Uncorrectables_Help(bool shortHelp)
54335433

54345434
void print_Corrupt_LBA_Help(bool shortHelp)
54355435
{
5436-
printf("\t--%s [lba]\t(Seagate Only)\n", CORRUPT_LBA_LONG_OPT_STRING);
5436+
printf("\t--%s [lba]\n", CORRUPT_LBA_LONG_OPT_STRING);
54375437
if (!shortHelp)
54385438
{
54395439
printf("\t\tUse this option to corrupt the data bytes of an LBA. The\n");
@@ -5448,7 +5448,7 @@ void print_Corrupt_LBA_Help(bool shortHelp)
54485448

54495449
void print_Corrupt_Random_LBAs_Help(bool shortHelp)
54505450
{
5451-
printf("\t--%s [# of LBAs to corrupt]\t(Seagate Only)\n", CORRUPT_RANDOM_LBAS_LONG_OPT_STRING);
5451+
printf("\t--%s [# of LBAs to corrupt]\n", CORRUPT_RANDOM_LBAS_LONG_OPT_STRING);
54525452
if (!shortHelp)
54535453
{
54545454
printf("\t\tThis option will corrupt the specified number of LBAs randomly\n");
@@ -5464,7 +5464,7 @@ void print_Corrupt_Random_LBAs_Help(bool shortHelp)
54645464

54655465
void print_Corrupt_Range_Help(bool shortHelp)
54665466
{
5467-
printf("\t--%s [# of LBAs]\t(Seagate Only)\n", CORRUPT_LBA_RANGE_LONG_OPT_STRING);
5467+
printf("\t--%s [# of LBAs]\n", CORRUPT_LBA_RANGE_LONG_OPT_STRING);
54685468
if (!shortHelp)
54695469
{
54705470
printf("\t\tThis option is used with the --%s option to\n", CORRUPT_LBA_LONG_OPT_STRING);
@@ -5474,7 +5474,7 @@ void print_Corrupt_Range_Help(bool shortHelp)
54745474

54755475
void print_Bytes_To_Corrupt_Help(bool shortHelp)
54765476
{
5477-
printf("\t--%s [# of bytes]\t(Seagate Only)\n", BYTES_TO_CORRUPT_LONG_OPT_STRING);
5477+
printf("\t--%s [# of bytes]\n", BYTES_TO_CORRUPT_LONG_OPT_STRING);
54785478
if (!shortHelp)
54795479
{
54805480
printf("\t\tUse this option to specify the number of data bytes to change\n");
@@ -5484,7 +5484,7 @@ void print_Bytes_To_Corrupt_Help(bool shortHelp)
54845484

54855485
void print_SCSI_FW_Info_Help(bool shortHelp)
54865486
{
5487-
printf("\t--%s (SAS Only)\n", SHOW_SCSI_FW_INFO_LONG_OPT_STRING);
5487+
printf("\t--%s (SAS Only) (Seagate Only)\n", SHOW_SCSI_FW_INFO_LONG_OPT_STRING);
54885488
if (!shortHelp)
54895489
{
54905490
printf("\t\tThis option will show the SCSI Firmware info from\n");

utils/C/openSeaChest/openSeaChest_Defect.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
////////////////////////
3535
// Global Variables //
3636
////////////////////////
37-
const char* util_name = "openSeaChest_Defect";
38-
const char* buildVersion = "0.9.0";
37+
const char* util_name = "openSeaChest_Defect";
38+
const char* buildVersion = "0.9.1";
3939

4040
////////////////////////////
4141
// functions to declare //
@@ -1707,10 +1707,11 @@ void utility_Usage(bool shortUsage)
17071707
print_SCSI_Defects_Format_Help(shortUsage);
17081708
print_SCSI_Defects_Help(shortUsage);
17091709

1710-
// data destructive commands - alphabetized
1711-
printf("Data Destructive Commands (Seagate only)\n");
1712-
printf("========================================\n");
1713-
// utility data destructive tests/operations go here
1710+
1711+
//data destructive commands - alphabetized
1712+
printf("Data Destructive Commands\n");
1713+
printf("=========================\n");
1714+
//utility data destructive tests/operations go here
17141715
print_Bytes_To_Corrupt_Help(shortUsage);
17151716
print_DST_And_Clean_Help(shortUsage);
17161717
print_Corrupt_LBA_Help(shortUsage);

utils/C/openSeaChest/openSeaChest_PowerControl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
////////////////////////
3535
// Global Variables //
3636
////////////////////////
37-
const char* util_name = "openSeaChest_PowerControl";
38-
const char* buildVersion = "3.6.0";
37+
const char *util_name = "openSeaChest_PowerControl";
38+
const char *buildVersion = "3.6.1";
3939

4040
////////////////////////////
4141
// functions to declare //

utils/C/openSeaChest/openSeaChest_Security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ int main(int argc, char* argv[])
463463
}
464464
else if (strcmp(longopts[optionIndex].name, ATA_SECURITY_MASTER_PW_ID_LONG_OPT_STRING) == 0)
465465
{
466-
if (!get_And_Validate_Integer_Input_Uint16(optarg, M_NULLPTR, &ATA_SECURITY_MASTER_PW_ID))
466+
if (!get_And_Validate_Integer_Input_Uint16(optarg, M_NULLPTR, ALLOW_UNIT_NONE, &ATA_SECURITY_MASTER_PW_ID))
467467
{
468468
print_Error_In_Cmd_Line_Args(ATA_SECURITY_MASTER_PW_ID_LONG_OPT_STRING, optarg);
469469
exit(UTIL_EXIT_ERROR_IN_COMMAND_LINE);

0 commit comments

Comments
 (0)