Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDEnYO committed Sep 5, 2024
1 parent 2f2c3d2 commit 56a4c4d
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 8 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/verifyAudit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,20 @@ jobs:
if: env.AUDIT_REQUIRED == 'true'
run: |
echo "A"
# load list of protected contracts
PROTECTED_CONTRACTS=$(cat protected_contracts.txt)
echo "B"
# create temp files to store commit hashes and auditor handles
COMMIT_HASHES_FILE="commit_hashes.txt"
AUDITOR_GIT_HANDLES_FILE="auditor_handles.txt"
echo "C"
##### make sure that there are any protected contracts
if [[ -z $PROTECTED_CONTRACTS ]]; then
echo -e "\033[31mNo protected contracts found. This should not happen (action should stop earlier). Please check the code of the Github action. Aborting now.\033[0m"
echo "CONTINUE=false" >> $GITHUB_ENV
exit 1
fi
echo "D"
# iterate through all contracts
while IFS= read -r FILE; do
echo "now processing file $FILE"
Expand All @@ -182,8 +178,8 @@ jobs:
echo "AUDIT_IDS: $AUDIT_IDS"
# Properly count the number of audit IDs by splitting on newlines
AUDIT_COUNT=$(echo "$AUDIT_IDS" | tr ' ' '\n' | grep -c .)
# Count the number of audits found
AUDIT_COUNT=$(echo "$AUDIT_IDS" | wc -l)
echo "AUDIT_COUNT: $AUDIT_COUNT"
Expand Down Expand Up @@ -291,9 +287,9 @@ jobs:
echo "$AUDITOR_GIT_HANDLE" >> auditor_handles.txt
echo "E"
echo -e "\033[32mAn audit was found for contract $FILENAME.\033[0m"
done <<< "$PROTECTED_CONTRACTS"
echo -e "\033[32mAll audit log entries are complete.\033[0m"
# # read the temp files into variables
Expand Down
8 changes: 7 additions & 1 deletion audit/auditLog.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@
"StargateFacetV2": {
"1.0.1": ["audit20240814"]
},
"ContractName": {
"ContractOneAudit": {
"1.0.0": ["audit20240814"]
},
"ContractMultipleAudits": {
"1.0.0": ["audit20240814"]
},
"ContractInvalidAudit": {
"1.0.0": ["audit20250814"]
}
}
}
52 changes: 52 additions & 0 deletions src/Facets/ContractInvalidAudit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { LibDiamond } from "../Libraries/LibDiamond.sol";
import { LibAccess } from "../Libraries/LibAccess.sol";
import { CannotAuthoriseSelf } from "../Errors/GenericErrors.sol";

/// @title Access Manager Facet
/// @author LI.FI (https://li.fi)
/// @notice Provides functionality for managing method level access control
/// @custom:version 1.0.0
contract ContractInvalidAudit {
/// Events ///

event ExecutionAllowed(address indexed account, bytes4 indexed method);
event ExecutionDenied(address indexed account, bytes4 indexed method);

/// External Methods ///

/// @notice Sets whether a specific address can call a method
/// @param _selector The method selector to set access for
/// @param _executor The address to set method access for
/// @param _canExecute Whether or not the address can execute the specified method
function setCanExecute(
bytes4 _selector,
address _executor,
bool _canExecute
) external {
if (_executor == address(this)) {
revert CannotAuthoriseSelf();
}
LibDiamond.enforceIsContractOwner();
_canExecute
? LibAccess.addAccess(_selector, _executor)
: LibAccess.removeAccess(_selector, _executor);
if (_canExecute) {
emit ExecutionAllowed(_executor, _selector);
} else {
emit ExecutionDenied(_executor, _selector);
}
}

/// @notice Check if a method can be executed by a specific address
/// @param _selector The method selector to check
/// @param _executor The address to check
function addressCanExecuteMethod(
bytes4 _selector,
address _executor
) external view returns (bool) {
return LibAccess.accessStorage().execAccess[_selector][_executor];
}
}
52 changes: 52 additions & 0 deletions src/Facets/ContractMultipleAudits.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { LibDiamond } from "../Libraries/LibDiamond.sol";
import { LibAccess } from "../Libraries/LibAccess.sol";
import { CannotAuthoriseSelf } from "../Errors/GenericErrors.sol";

/// @title Access Manager Facet
/// @author LI.FI (https://li.fi)
/// @notice Provides functionality for managing method level access control
/// @custom:version 1.0.0
contract ContractMultipleAudits {
/// Events ///

event ExecutionAllowed(address indexed account, bytes4 indexed method);
event ExecutionDenied(address indexed account, bytes4 indexed method);

/// External Methods ///

/// @notice Sets whether a specific address can call a method
/// @param _selector The method selector to set access for
/// @param _executor The address to set method access for
/// @param _canExecute Whether or not the address can execute the specified method
function setCanExecute(
bytes4 _selector,
address _executor,
bool _canExecute
) external {
if (_executor == address(this)) {
revert CannotAuthoriseSelf();
}
LibDiamond.enforceIsContractOwner();
_canExecute
? LibAccess.addAccess(_selector, _executor)
: LibAccess.removeAccess(_selector, _executor);
if (_canExecute) {
emit ExecutionAllowed(_executor, _selector);
} else {
emit ExecutionDenied(_executor, _selector);
}
}

/// @notice Check if a method can be executed by a specific address
/// @param _selector The method selector to check
/// @param _executor The address to check
function addressCanExecuteMethod(
bytes4 _selector,
address _executor
) external view returns (bool) {
return LibAccess.accessStorage().execAccess[_selector][_executor];
}
}
File renamed without changes.
52 changes: 52 additions & 0 deletions src/Facets/ContractOneAudit.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import { LibDiamond } from "../Libraries/LibDiamond.sol";
import { LibAccess } from "../Libraries/LibAccess.sol";
import { CannotAuthoriseSelf } from "../Errors/GenericErrors.sol";

/// @title Access Manager Facet
/// @author LI.FI (https://li.fi)
/// @notice Provides functionality for managing method level access control
/// @custom:version 1.0.0
contract ContractOneAudit {
/// Events ///

event ExecutionAllowed(address indexed account, bytes4 indexed method);
event ExecutionDenied(address indexed account, bytes4 indexed method);

/// External Methods ///

/// @notice Sets whether a specific address can call a method
/// @param _selector The method selector to set access for
/// @param _executor The address to set method access for
/// @param _canExecute Whether or not the address can execute the specified method
function setCanExecute(
bytes4 _selector,
address _executor,
bool _canExecute
) external {
if (_executor == address(this)) {
revert CannotAuthoriseSelf();
}
LibDiamond.enforceIsContractOwner();
_canExecute
? LibAccess.addAccess(_selector, _executor)
: LibAccess.removeAccess(_selector, _executor);
if (_canExecute) {
emit ExecutionAllowed(_executor, _selector);
} else {
emit ExecutionDenied(_executor, _selector);
}
}

/// @notice Check if a method can be executed by a specific address
/// @param _selector The method selector to check
/// @param _executor The address to check
function addressCanExecuteMethod(
bytes4 _selector,
address _executor
) external view returns (bool) {
return LibAccess.accessStorage().execAccess[_selector][_executor];
}
}

0 comments on commit 56a4c4d

Please sign in to comment.